in reply to Changing string in specific line/position in a file

It is worth noting that a file is essentially an array of bytes. There is no way to 'jump' to a file - without streaming through the file finding every new line characters.

My suggestion would be to set perl's record separator to the end of page sequence, then 'slurp' each page. For each page: extract the value you want with a match regexp, and update the value with a subsitution regex. Then write the page to a new file.

Example:
open my $in , "<", 'input.txt'; open my $out, ">", 'output.txt'; $/ = "^L"; # Set the end of page sequence while (my $page = <$in>) # Get page { if ($page =~ m/\nINVENTORY +(\d+-\d+)/) # Get the inventory number { my $inventorNumber = $1; # do your database lookup to get new date from inventory number my $date = doDatabaseLookup($inventoryNumber); # Replace the existing date with the new date $page =~ s/(\nMY COMPANY PRODUCT #\n\d+ +)(\d{8})/$1$date/; } print out $page; }