first: ++davorg for already providing the really real right answer. in perl, there's always MTOWTDI, but some are better than others, and ones other people have already written properly and debugged are often best.
if you really want a regex to get everything after the last /, i think the easiest way is
though maybe you prefer(my $file = $url) =~ s~^.*/~~;
my ($file) = $url =~ m~([^/]*)$~;
i also wanted to point out that in BigJoe's solution it is more idiomatically perl to say $array[-1] than $array[$#array]. this is useful to me because it may not always be clear how to get the last valid index of an array that is, say, stored as the second item in an anonymous array reffed by a hash entry... meaning $hash{stuff}[1]. but &091;-1&093; always works
.update: as per the tachyon beam. no, i didn't test it because at the moment i am away from easy perl access. mea culpa. fixx0red.
.In reply to Re: Get the filename from the end of a URL
by Vynce
in thread Get the filename from the end of a URL
by ip9
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |