ravi45722 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use warnings; use strict; # open your file using a filehandle called MYFILE open(MYFILE, "/root/prac/packages/test.txt"); my $data; while (<MYFILE>) { chomp; print <MYFILE>; #printing each line. Before e +nding the loop it prints entire file $data = join "", <MYFILE>; } print $data,"\n"; #prints entire file
My test.txt file contains
1st line 2nd line 3rd line 4th line End of file
Through these I expected the output is like it will print the entire file two times.But the o/p is
[root@ems packages]# perl variable_entire_file.pl 2nd line 3rd line 4th line Ending the file
Then I got doubt which line is printing either print <MYFILE> or print $data,"\n"; Afetr that i commented one by one. If i commented any one of two lines its giving the same output with the 1st line missing. Why its not printing two times. Why my 1st line missing
|
|---|