in reply to Launch Windows Explorer from Windows DOS prompt
no need to read the directory twice .. few options:
- read into a @listing array, and grep that to make @dirs and @files
- read as little as possible w/a loop like:
my ($dir, $file); while( readdir DIR ){ if( -d ){ $dir = $_; last; } $file ||= $_; } close DIR; $cwd .= "/" . ($dir || $file || '.'); $cwd =~ s#/#\\#g; warn $cwd;
- read whole thing and sort:
my @listing = sort { -d $b <=> -d $a || $a cmp $b } grep { ! /^\.\.?$/ + } readdir DIR; $cwd .= "/" . ($listing[0] || '.'); $cwd =~ s#/#\\#g;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Launch Windows Explorer from Windows DOS prompt
by larryl (Monk) on Apr 14, 2006 at 21:14 UTC | |
by davidrw (Prior) on Apr 14, 2006 at 21:57 UTC |
In Section
Cool Uses for Perl