Hir@ has asked for the wisdom of the Perl Monks concerning the following question:
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 wereThen i wrote the following scriptSidra|38|BE Hira|48|BE Shagufta|50|BE
the script produces no output and displays a message sayingopen(DAT, "text.txt"); $data_file=" text.txt "; open(DAT, $data_file); @raw_data=; 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 $cla +ss"; print " \n"; }
"readline () closed filehandle at line "
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...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: reading input from a file
by Utilitarian (Vicar) on Feb 06, 2010 at 22:26 UTC | |
|
Re: reading input from a file
by toolic (Bishop) on Feb 06, 2010 at 23:23 UTC | |
by Hir@ (Initiate) on Feb 09, 2010 at 11:41 UTC |