Hi Jim,

>>but why it is not /local/bin/perl? will .*/ matches longest possible
string?

.  means any character
*  means preceding character any number of times (zero or more), so  .*
means any character (but not a new line) any number of times

Now  .*/  means any number of characters but should end with  /

Which in this case would match till the last  /   i.e string -
/usr/local/bin/

And finally you are replacing the above string with nothing so remaining
string i.e 'perl' is getting stored in $basename

Cheers,
Parag




On Sun, Jan 17, 2010 at 9:55 PM, Jim Green
<student.northwest...@gmail.com>wrote:

> my $name = "/usr/local/bin/perl";
> (my $basename = $name) =~ s#.*/##; # Oops!
>
> after substitution $basename is supposed to be
> perl
>
> but why it is not /local/bin/perl? will .*/ matches longest possible
> string?
>
> Thank you list!
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>

Reply via email to