Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Re: Extracting just the extension from a filename.by simeon2000 (Monk) |
on Jul 19, 2002 at 20:18 UTC ( [id://183438]=note: print w/replies, xml ) | Need Help?? |
Good solution. My only additions would be to use \^\.\ instead of \w to catch \W as well but not ".". You could also one-line it by catching the matches with alist assignment to avoid reading from $1: my ($extension) = $filename =~ /\.([^\.]+)$/;
In Section
Seekers of Perl Wisdom
|
|