Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: list files in a directory

by ChOas (Curate)
on Jan 19, 2001 at 19:16 UTC ( [id://52997]=note: print w/replies, xml ) Need Help??


in reply to list files in a directory

I think you should have posted this Seekers
for Perl wisdom... but anyways...

sub ArchiveDir { my $Directory=shift||'.'; my $OutputFile=shift||'dircontents.txt'; opendir INDIR,$Directory or die "Cannot open $Directory: $!\n"; open OUTFILE,">$OutputFile" or die "Cannot open $OutputFile for outpu +t: $!\n"; print OUTFILE "$Directory/$_\n" for (readdir(INDIR)); close OUTFILE; closedir INDIR; };
OR:
sub ArchiveDir { my $Directory=shift||'.'; my $OutputFile=shift||'dircontents.txt'; open OUTFILE,">$OutputFile" or die "Cannot open $OutputFile for outpu +t: $!\n"; print OUTFILE "$_\n" for <$Directory/*>; close OUTFILE; };

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-04-24 07:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found