megankong
03-14-2006, 05:30 PM
Hi,
I am trying to reading two files, both are sectioned by blank line. I have used the following code to set the reading in paragraph mode:
print "Please enter the file name: \n";
$filename1 = <STDIN>;
unless(open(DATAFILE1, $filename1)){
die ("Could not open file $filename1\n");
exit;
}
$/ = ""; set the paragraph reading mode
while(my $rec1 = <DATAFILE1>) {
push @tmp1, $rec1;
}
##However, after this reading I can no longer reading the
##file name from the command line, why?
print "Please enter the file name: \n";
$filename2 = <STDIN>;
## the program will come to a halt after I enter the second
## file name, I think I need to exit the paragraph reading ##mode, but HOW?
unless(open(DATAFILE2, $filename2)){
die ("Could not open file $filename2\n");
exit;
}
while(my $rec2 = <DATAFILE2>) {
push @tmp2, $rec2;
}
exit;
Thank you
I am trying to reading two files, both are sectioned by blank line. I have used the following code to set the reading in paragraph mode:
print "Please enter the file name: \n";
$filename1 = <STDIN>;
unless(open(DATAFILE1, $filename1)){
die ("Could not open file $filename1\n");
exit;
}
$/ = ""; set the paragraph reading mode
while(my $rec1 = <DATAFILE1>) {
push @tmp1, $rec1;
}
##However, after this reading I can no longer reading the
##file name from the command line, why?
print "Please enter the file name: \n";
$filename2 = <STDIN>;
## the program will come to a halt after I enter the second
## file name, I think I need to exit the paragraph reading ##mode, but HOW?
unless(open(DATAFILE2, $filename2)){
die ("Could not open file $filename2\n");
exit;
}
while(my $rec2 = <DATAFILE2>) {
push @tmp2, $rec2;
}
exit;
Thank you