in reply to File APPEND/OVERWRITE

If you are not using autodie, then you should be checking the status of each of your open statements, e.g.:
open(my $fh, ">>", $myfile) or die "Failed to open $myfile: $!";
Similarly, you should also check the status of chdir

Replies are listed 'Best First'.
Re^2: File APPEND/OVERWRITE
by he204035 (Novice) on Feb 09, 2012 at 17:24 UTC

    I tried the "or die" and the files all seem to be opening fine...(no death notices.. :-)

    I am wondering about something...earlier in my code, I have a line of code to do a "mkdir", which I assumed would act the same as if I was doing it by hand...i.e. if a mkdir is entered on a subdirectory that already exists, it will just go in with life...:

    foreach (@text) { $first = substr($_,0,11); mkdir "$first"; print "Copying $_ to $first.\n"; copy($_,"$first/$_"); unlink $_; }

    I am wondering if that "mkdir" is actually re-creating the sub-directories, which if so I guess would wipe out anything that was in there previously?

      I am wondering if that "mkdir" is actually re-creating the sub-directories
      Not really. Try it:
      mkdir 'XXX'; open my $FH, '>', 'XXX/1'; close $FH; mkdir "XXX" or warn $!; open my $FH, '<', 'XXX/1' or die $!; close $FH;