t-rex has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks, I want to test if a file with name tpsm exists, and my folder might contain many file such as
tpsm_01 tpsm_12 tpsm_23 . . . and so on
the above code didnt work as i didnt have exact file name , on the shell we can directly use file* to check for multiple files with the same name ( some part of the name) but how fdo i check here?
basically i want to test if a file with name tpsm _x exists or not, i don't know what will be the value of x , but i just want to know if files having such names are there or not. i tried with
$pwd = $ENV{'PWD'}; $file = "$pwd/tpsm*"; if (-e $file) { #do something }
please let me know how can i achieve this
i am using glob and its working fine , thanks @Corion and @steveib
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: finding a file exist amongst many files
by stevieb (Canon) on Aug 25, 2016 at 14:07 UTC | |
by t-rex (Scribe) on Aug 25, 2016 at 14:15 UTC | |
by Corion (Patriarch) on Aug 25, 2016 at 14:22 UTC | |
by stevieb (Canon) on Aug 25, 2016 at 14:27 UTC | |
by t-rex (Scribe) on Aug 26, 2016 at 08:57 UTC | |
by Anonymous Monk on Aug 26, 2016 at 09:15 UTC | |
Re: finding a file exist amongst many files
by Marshall (Canon) on Aug 25, 2016 at 16:53 UTC |