http://qs321.pair.com?node_id=173112


in reply to Re: Regular Expression Assistance
in thread Regular Expression Assistance

If you know the absolute filename and want to open that file, what prevents you from doing just that?

_Ass_uming safe input data here:

my $filename = $ARGV[0] or die "No filename given\n"; open INPUT, "<", $filename or die "could not open $filename\n"; while (<INPUT>) { print $_ }; close INPUT;
Anyway:
If the complete filename is in $filename you can do:
my ($file_without_path) = $filename =~ /^.*?\/(\w*?\w*?\.ext)$/;

and end up with something like: "file23432545335.ext"

Still, I don't see the point if you trust the filename as being safe, and just want to open it. (Since you will need the path anyway).

janx