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
In reply to problem in outputting files to a new directory by mehul79
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |