mehul79 has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to output the file to a new directory ( the files to be mo +dified is in another folder) but iam getting the error cannot open directory My code : #!/usr/local/bin/perl -w # use strict; # use warnings; if($#ARGV != 1) { print "usage: perl directory.pl source direcoty detination direct +ory \n"; exit; } chomp(@ARGV); #my $dirname = "lab"; #my $output="lab2"; my $dirname = $ARGV[0]; my $output= $ARGV[1]; $dirname =~ s/\/$//g; $output =~ s/\/$//g; mkdir $output if (-d $output ==0); #`rm $output/*.lab`; opendir(DIR, $dirname) or die "can't opendir $dirname: $!"; while (defined($file = readdir(DIR))) { $file2=$file; $input=$dirname."/".$file; $out=$output."/".$file2; print $file."\t".$input."\t".$out."\n"; open(F,"<$input") or die " Cannot open file $input: $!"; open(F1,">$out") or die " Cannot open file $out: $!"; <F>; #while ($line = readline(F)) { #$line=~s/^(.*)\n$/$1/s; #$line=~ s/\r//gi; #print F1 $line ; #} close (F); close (F1); } closedir(DIR);
Original content restored by GrandFather
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problem in outputting files to a new directory
by GrandFather (Saint) on Aug 27, 2009 at 04:16 UTC | |
|
Re: problem in outputting files to a new directory
by jwkrahn (Abbot) on Aug 27, 2009 at 05:51 UTC | |
|
Re: problem in outputting files to a new directory
by BioLion (Curate) on Aug 27, 2009 at 08:28 UTC | |
by ww (Archbishop) on Aug 27, 2009 at 10:58 UTC |