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
open(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"; }
the script produces no output and displays a message saying

"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...

In reply to reading input from a file by Hir@

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.