The seek Function randomly accesses a file: seek(FILEHANDLE, BYTEOFFSET, FILEPOSITION);
#Positions are
#0 = Beginning of the file
#1 = Current position in the file
#2 = End of the file
open(FH,"db") or die "Can't open: $!\n";
while($line=<FH>){
if ($line =~ /LLLL/) {
print "--$line--\n";
}
}
seek(FH,0,0);
while(<FH>) {
print if /Sss/;
}
Related examples in the same category