<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Hir@</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/hir/" />
    <link rel="self" type="application/atom+xml" href="http://blogs.perl.org/users/hir/atom.xml" />
    <id>tag:blogs.perl.org,2009-11-03:/users/hir//237</id>
    <updated>2010-02-06T15:09:04Z</updated>
    <subtitle>A blog about the Perl programming language</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.38</generator>

<entry>
    <title>reading input from a file</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/hir/2010/02/reading-input-from-a-file.html" />
    <id>tag:blogs.perl.org,2010:/users/hir//237.251</id>

    <published>2010-02-06T15:07:16Z</published>
    <updated>2010-02-06T15:09:04Z</updated>

    <summary>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 &quot;text.txt&quot;...</summary>
    <author>
        <name>Hir@</name>
        
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/hir/">
        <![CDATA[<p>hello...<br />
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:</p>

<p>i made a text file by the name "text.txt" and the contents were<br />
Sidra|38|BE<br />
Hira|48|BE<br />
Shagufta|50|BE</p>

<p>Then i wrote the following script</p>

<p>open(DAT, "text.txt"); <br />
$data_file=" text.txt ";<br />
open(DAT, $data_file); <br />
@raw_data=<DAT>;<br />
close(DAT);<br />
foreach $student (@raw_data)<br />
{<br />
chomp($student);<br />
($name,$roll_no,$class)=split(/\|/,$student);<br />
print "The student $name bearing roll number $roll_no is in class $class";<br />
print "<br>\n";<br />
}</p>

<p><br />
the script produces no output and displays a message saying<br />
"readline () closed filehandle at <filename> line <line number>"<br />
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.<br />
Thankyou...</p>]]>
        
    </content>
</entry>

</feed>
