I "think" I am closing the filehandle after I create the STEP2 file, but before I access the second time for reading.

At least I think I am.

Here is a shortened version of the code:

######################## # OPEN THE STEP 1 FILE # ######################## foreach (@files) { chdir($dir1); ## Verify Files exist die "File: $_ does not exist. \n $!" unless -e ; ## Verify Files are read/writable die "File: $_ isn't read or writable \n $!" unless ((-r $_ ) && (-w $_ )); ### Open the file open (FILE, "<", $_ ) or die "Cannot open the file $! \n"; select((select(FILE), $/ = undef)[0]); my @array_contents = <FILE>; close (FILE) or die $!;; ## DO SOME STUFF ########################## # CREATE THE STEP 2 FILE # ########################## chdir($dir2); $outputfile = "STEP2_" . $_; open(OUTFILE, ">" , $outputfile) or die $!; print OUTFILE $contents; close OUTFILE or die $!; }; ########################## # ACCESS THE STEP 2 FILE # ########################## chdir($dir2); open (SFCOMMENTS, "<STEP2_CaseComment.csv") or die "Cannot open Salesf +orce Comments file $! \n"; $count = 0; while (<SFCOMMENTS>) { print "Count is: $count \n"; $count ++; } close SFCOMMENTS or die $!;

In reply to Re^2: Opening a File Twice by Jamin
in thread Opening a File Twice by Jamin

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.