Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: finding a file exist amongst many files

by t-rex (Scribe)
on Aug 25, 2016 at 14:15 UTC ( [id://1170441]=note: print w/replies, xml ) Need Help??


in reply to Re: finding a file exist amongst many files
in thread UPDATE :: finding a file exist amongst many files

thanks for the reply steve. basically i am looking for if a file with tpsm_x exists, so on the shell it is pretty easy to find this. i want to know its perl counterpart, nevertheless i can try this but i don't want to install this package(legacy code issues).

  • Comment on Re^2: finding a file exist amongst many files

Replies are listed 'Best First'.
Re^3: finding a file exist amongst many files
by Corion (Patriarch) on Aug 25, 2016 at 14:22 UTC
Re^3: finding a file exist amongst many files
by stevieb (Canon) on Aug 25, 2016 at 14:27 UTC

    Take two, with builtins only. Note that with readdir, it doesn't keep the whole path, so you have to add it back manually:

    use warnings; use strict; my $dir = 'test'; opendir my $dh, $dir or die $!; while (readdir $dh){ if (/tpsm_.*/ && -f "$dir/$_"){ print "$dir/$_ is a file\n"; } }

    update: or use glob as Corion said :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found