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
24 weeks 10 hours ago
24 weeks 4 days ago
24 weeks 4 days ago
24 weeks 6 days ago
25 weeks 4 days ago
27 weeks 5 days ago
30 weeks 5 days ago
33 weeks 4 days ago
34 weeks 2 days ago
35 weeks 23 hours ago