From: Stefan Lidman <[EMAIL PROTECTED]>
> >Can someone translate into English:
> >
> >($filename) = $file =~ m!([^/]*)$!;
> >
> >
> >Why is $filename in parens?
> 
> The parens put $filename in list context so that it contains whatever
> is after the last '/'.

This sentence may be a little misleading. (Even though it IS basicaly 
correct!)

        The parend put $filename in list context. In list context a regex 
match returns a list of strings that matched the groups in the regex. 
In this case there is only one group so that list will have only one 
item and that item will be assigned to $filename.

Now the regexp matches all non-slashes at the end of the string 
(which is NOT the same as "the stuff after the last slash"! There 
doesn't have to be any slash for this regesp to match!) so the 
$filename ends up containing the last part of the path in $file.
(Wow this is long)

See
        my $str = 'ABCDE';
        my ($x, $y, $z) = $str =~ /(.)(.)(..)/;
        print "$x, $y, $z\n";

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to