use strict; my @files = qw(CaseComment.csv); my $dir1 = "."; my $dir2 = "."; ######################## # OPEN THE STEP 1 FILE # ######################## foreach (@files) { my $filename = "$dir1/$_"; #chdir($dir1); # replace by "$dir/$_" # Redundant - open() will die with # an informative message anyway ## Verify Files exist #die "File: '$filename' does not exist: $!" # unless -e $filename; ## Verify Files are read/writable #die "File: $filename isn't read or writable \n $!" # unless ((-r $filename ) && (-w $filename )); ### Open the file open (FILE, "<", $filename ) or die "Cannot open the file '$filename': $!\n"; #select((select(FILE), $/ = undef)[0]); # what is that for? my @array_contents = ; close (FILE) or die $!; ## DO SOME STUFF ########################## # CREATE THE STEP 2 FILE # ########################## #chdir($dir2); my $contents = <" , $outputfile) or die "Couldn't create '$outputfile':$!"; print OUTFILE $contents; close OUTFILE or die $!; }; ########################## # ACCESS THE STEP 2 FILE # ########################## #chdir($dir2); my $commentsfile = "$dir2/STEP2_CaseComment.csv"; open (SFCOMMENTS, "<", $commentsfile) or die "Cannot open Salesforce Comments file '$commentsfile' : $! \n"; my $count = 0; while () { print "Count is: $count \n"; $count ++; } close SFCOMMENTS or die $!; #### C:\Projekte>perl -w tmp.pl Writing 'Line 1 line 2 linE 3 ' at tmp.pl line 44. Count is: 0 Count is: 1 Count is: 2