[Courses] [Perl] Part 6: The "m//" Operator

Isabelle & Zohar Stolar stolar at numericable.fr
Tue Aug 12 19:48:45 EST 2003


>
> Finally, let me say that I am quite pleased to see your response, because
> up until now I have seen no response whatsoever, and I was beginning to
> wonder if anyone at all was benefiting from the course!
>

Don't be sad Dan - You have you're faithful audience :-)

Here's my solution:
--------------------------------------------------------------
my ($prot, $auth, $path) ;
while ( defined( my $input = <STDIN> )) {
    if ($input =~ /(\s*[a-z]*):\/\/([\w.]+)\/(.*)/) {
        ( $prot, $auth, $path ) = ( $input =~
/(\s*\w*):\/\/([\w.]+)\/(.*)/ ) ;  # it's not a double-u it's "\ / \ /"
        print "protocol = $prot\n" ;
        print "authority = $auth\n" ;
        print "path = $path\n" ;
    }
    else {
        print "$input cannot be parsed" ;
    }
}
---------------------------------------------------------------

Thanks for your lessons,
Zohar.




More information about the Courses mailing list