Mega Code Archive

 
Categories / Perl / File
 

The seek Function randomly accesses a file

#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/; }