John W. Krahn wrote:
Hi John
[snip OP]
use warnings;
use strict;
my $path = $ARGV[ 0 ];
open FILE, '>', 'c:/filelist.txt' or die "Can't open c:/filelist.txt: $!";
opendir DIR, $path or die "Can't open $path: $!";
print FILE map /^\.\.?$/ ? () : "$_\n", readdir DIR;
I favour
print FILE "$_\n" foreach grep /[^.]/, readdir DIR;
for clarity
closedir DIR;
close FILE;
Or even
system "dir /b $path > C:/filelist.txt";
$? and die "Can't create C:/filelist.txt: $?"
since portability is not a question
Can you also let me know how to read the line in the below file, look for
the second and forth " and write the name of the file fetched in the
above program before the second and fourth " and between the fifth and
sixth
" one by one.
"SL/" "%HOME%/server/bin/" "" NA
as in
"SL/one" "%HOME%/server/bin/one" "one" NA
s/("[^"]*)("\s+"[^"]*)("\s+"[^"]*)("\s+NA)/$1$file$2$file$3$file$4/;
Again, I think
s/("[^"]*)(")/$1$file$2/g;
is less befuddling.
HTH,
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>