in reply to Re^2: auto increment
in thread auto increment
Better yet:
use feature 'say'; my $output = "data.txt"; open(DAT, '+<', $output) || die("Cannot Open File"); my $line; $line = <DAT> until eof DAT; my ($id) = $line =~ m/\A(\d+):/; say DAT join ':', ++$id, $name, $number, $address, $phone, $email; close(DAT);
This way, the regular expression is only executed once - on the last line.
Sorry for the double post, I can't edit my comments (not enough powers yet).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: auto increment
by PilotinControl (Pilgrim) on May 05, 2015 at 14:06 UTC |