Original Message----- From: Edward WIJAYA [mailto:[EMAIL PROTECTED] Sent: Monday, July 19, 2004 11:37 AM To: [EMAIL PROTECTED] Subject: Processing files in Multiple directories (Bash or Perl?)
Hi, I have a perl code, with usage: mycode.pl file.txt > file1.out Now I would like to execute this code for files in multiple directory (e.g. dir1, dir2, dir3, ...dir10). As I am new for both Bash and Perl, would like to know if it is be easier to do this with Perl or Bash? I have already have a bash script (didn't know how to proceed): ------------------------------- #!bin/bash for i in * do if [ -d $i ] then find $i -name '*.fa*' #perl mycode.pl $i > #????? don't know how to go from here fi done ------------------------------------- Would any body kindly advice? Thanks so much for your time. Hope to hear from you again Regards Edward WIJAYA SINGAPORE I find this easier to do but then I know perl better than bash... DEV,SUN2>./foo file1=a,b,c/d/e file2=x/f/g file3=/,home/cgi-bin Find file2 in Dirs = (x/f/g) Find file1 in Dirs = (a,b,c/d/e) Find file3 in Dirs = (/,home/cgi-bin) DEV,SUN2>more foo #! /usr/local/bin/perl use strict; my %params; foreach (@ARGV) { my ($file, $dirs)=split /=/; @{$params{$file}} = split /,/, $dirs; } foreach (keys %params) { print "Find $_ in Dirs = (", join (',', @{$params{$_}}), ')', "\n"; # do any "stuff" you want then call the already existing perl script # like see if the file exist in the dir before calling other script # or better yet - sub ... I develop lots of things in little blocks # get them working then combine... } DEV,SUN2> I also like the way read "reads" ... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>