Perl: Reading Files
In Perl, files can be read using handles as follows: Suppose, you want to read a following file called "program.txt" that contains following data using perl program:
1: perl 2: php 3: java 4: jsp
The program that would read this and print languages is:
#!/usr/bin/perl $fileName="program.txt"; open( fileHandle, $fileName); while(){ chop; # chop is used to remove \n ('end of line' from each line). my($id, $language) = split(':', $_); print "Language is $language \n"; }
The output of the above file is:
Language is perl Language is php Language is java Language is jsp

Recent comments
6 days 14 hours ago
2 weeks 4 days ago
3 weeks 6 days ago
4 weeks 2 days ago
4 weeks 3 days ago
4 weeks 5 days ago
29 weeks 19 hours ago
29 weeks 4 days ago
29 weeks 4 days ago
30 weeks 7 hours ago