Solution:
Sometime we need to print or show content from file on basis of line number.
Suppose we have a file, which contains 1000 of lines and we need to print the content from line number 30 to 50.
Following example will show, how can we do this :-
open FILE, "/location/filename";
while(<FILE>){
if($. > 29 && $. < 51){ # Here $. represents the line number
print $_; # Here $_ represents the content
}
}
close FILE;
Sometime we need to print or show content from file on basis of line number.
Suppose we have a file, which contains 1000 of lines and we need to print the content from line number 30 to 50.
Following example will show, how can we do this :-
open FILE, "/location/filename";
while(<FILE>){
if($. > 29 && $. < 51){ # Here $. represents the line number
print $_; # Here $_ represents the content
}
}
close FILE;