in reply to auto increment

You can read the whole file into the memory (@file) and take the id from the very last line.
open(DAT, "<$output") || die("Cannot Open File"); my @file = <DAT>; close DAT; my $id = (split(':', $file[-1]))[0]; $id++; print "$id\n";