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

No it does not work.

Works for me:

C:\test>perl -we"my $dir = 'c:\\program files\\'; print for `dir \"$di +r\" /s /b /o:-s`" c:\program files\7-Zip c:\program files\Bin c:\program files\Common Files c:\program files\Core Temp c:\program files\CPUID c:\program files\Direct Modeling Express 4.0 c:\program files\Extras c:\program files\GlowCode 9.0 c:\program files\Hitman Pro 3.5 ...

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Replies are listed 'Best First'.
Re^5: how to dir a directory that have space
by AtlasFlame (Novice) on Jan 18, 2015 at 11:05 UTC

    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";