Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^5: how to dir a directory that have space

by AtlasFlame (Novice)
on Jan 18, 2015 at 11:05 UTC ( [id://1113651]=note: print w/replies, xml ) Need Help??


in reply to Re^4: how to dir a directory that have space
in thread how to dir a directory that have space

It works ok if run it in single line. But when i put it in script it does not. Anyway i'm using below code to do the same and it's working ok. Basically i'm searching for newest specific file name in sub-folders that starts with "K"

opendir my $dh, $source_directory or die "error: open '$source_directo +ry'"; my @paths = grep { /^K/} readdir $dh; closedir $dh; $p=0; foreach (@paths){ opendir SUB_DIR,"$source_directory$paths[$p]"; while(our $file = readdir(SUB_DIR)) { if(($file =~ /$ID/) && ($file =~ /xls$/)){ @files = $file; @FilePath = "$source_directory$paths[$p]"; } } $p++; } print "\nFile = $FilePath[0]\\$files[0]\n";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-03-29 12:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found