in reply to R.Exp. Matching from the Right
i assume you want the file name, without the path - is it right?!
if so, try this:
if you want to print the path as well, just use print $&;
update
the code above will replace the path with nothing, so the result will be just the filename. you might recover the path later, as i said, using $&.
still, if you really only want to match, i guess Praveen's reply will be more suitable.
=)
(my $file = "c:/progra~1/apache~1/apache2/cgi-bin/test/new/Feb23-2006_ +0_test_error.txt")=~ s/.*\///g; print $file;
if you want to print the path as well, just use print $&;
update
the code above will replace the path with nothing, so the result will be just the filename. you might recover the path later, as i said, using $&.
still, if you really only want to match, i guess Praveen's reply will be more suitable.
=)
|
---|
In Section
Seekers of Perl Wisdom