hello...
i have recently started learning perl.....and having issues when i try to read input from another file. the details of a script that i tried to run are as follows:
i made a text file by the name “text.txt” and the contents were
Sidra|38|BE
Hira|48|BE
Shagufta|50|BE
Then i wrote the following script
the script produces no output and displays a message saying
“readline () closed filehandle at <filename> line <line number>”
I tried the same with another file by the name “text.dat” holding the same data but it did not work either. Please help me out resolving this issue.
Thankyou...
i have recently started learning perl.....and having issues when i try to read input from another file. the details of a script that i tried to run are as follows:
i made a text file by the name “text.txt” and the contents were
Sidra|38|BE
Hira|48|BE
Shagufta|50|BE
Then i wrote the following script
Code:
open(DAT, "text.txt");
$data_file=" text.txt ";
open(DAT, $data_file);
@raw_data=<DAT>;
close(DAT);
foreach $student (@raw_data)
{
chomp($student);
($name,$roll_no,$class)=split(/\|/,$student);
print "The student $name bearing roll number $roll_no is in class $class";
print "<br>\n";
}
“readline () closed filehandle at <filename> line <line number>”
I tried the same with another file by the name “text.dat” holding the same data but it did not work either. Please help me out resolving this issue.
Thankyou...
Comment