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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.