in reply to reading input from a file
Post your actual code in code tags: see Writeup Formatting Tips.
From the code you have shown, there seems to be no need to read your whole file into an array; you could read it in line-by-line and process it as you go. That would save memory if your input file is large. UNTESTED:
use strict; use warnings; my $file = 'text.txt'; open my $fh, '<', $file or die "can not open $file: $!"; while (<$fh>) { chomp; my ($name, $roll_no, $class) = split /\|/; print "The student $name bearing roll number $roll_no is in class +$class\n"; } close $fh;
If you really do need to read the file into an array, you could slurp that file (and slurp it good!): File::Slurp.
Updated with code example.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: reading input from a file
by Hir@ (Initiate) on Feb 09, 2010 at 11:41 UTC |