Often I need to extract the file name from a path. Typically I do
something like following. Any better ways I could do this?
#path test
$current_file = "c:/somedir/test.ps";
@split_path = split("/",$current_file);
$current_file = @split_path[-1];
print $current_file;
However, I'm pretty sure I could extract the file name using a regular
expression. How might I do this? Any suggestions welcome.
Thanks
Let greediness work for you:
$path="c:/somedir/test.ps";
$path=~/.*\/(.+)/;
$file=$1;
print "$file";
_________________________________________________________________
Cant afford to quit your job? Earn your AS, BS, or MS degree online in 1
year.
http://www.classesusa.com/clickcount.cfm?id=866145&goto=http%3A%2F%2Fwww.classesusa.com%2Ffeaturedschools%2Fonlinedegreesmp%2Fform-dyn1.html%3Fsplovr%3D866143
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs