I found this snippet of code in the PERL for system administration book last week while I was reading it.
opendir(DIR,".") or die "Can't open the current directory: $!\n"; @names = readdir(DIR) or die "Unable to read current dir:$!\n"; closedir(DIR); foreach $name (@names) { # do stuff here } I hope this helps -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of zentara Sent: Wednesday, January 12, 2005 6:58 AM To: beginners@perl.org Subject: Re: encoding script On Wed, 12 Jan 2005 08:03:19 +0000, [EMAIL PROTECTED] (Saurabh Singhvi) wrote: >HI all, > >i want to write a perl script in linux that would get the file names >in the directory i am running it in and then execute a system command >for each file.(the encoding line). how should i go about it?? > >thnx in adv >Saurabh > >PS:- i think i would be using "syscall" but i am confused about the >file name changing thing Here is one way: #!/usr/bin/perl use File::Find; my $path = '.'; finddepth (\&wanted,$path); sub wanted { my $old = $_; return unless -f; #-d for dir ops or comment out for both system("d2u -U -b -v $_") or warn "$!\n"; } __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>