in reply to reading input from a file
use strict; # these two lines will save you use warnings; # endless head scratching open(DAT, "text.txt"); # you open this file again in two lines $data_file="<text.txt "; # three argument version of open is preferabl +e open(DAT, $data_file); # you should check the return value of open @raw_data=<DAT>; # Assumed this was what the line said 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"; }
|
|---|