Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: Regular Expression Assistance

by janx (Monk)
on Jun 10, 2002 at 13:23 UTC ( [id://173112]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://173112]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-04-18 23:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found