Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Re: Regular Expression Assistance

by janx (Monk)
on Jun 10, 2002 at 13:23 UTC ( #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? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2023-03-28 18:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (68 votes). Check out past polls.

    Notices?