in reply to Re: Opening a File Twice
in thread Opening a File Twice
######################## # 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 $!;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Opening a File Twice
by apl (Monsignor) on May 28, 2008 at 14:39 UTC | |
|
Re^3: Opening a File Twice
by Corion (Patriarch) on May 28, 2008 at 15:14 UTC | |
|
Re^3: Opening a File Twice
by starbolin (Hermit) on May 28, 2008 at 19:57 UTC |