in reply to File modification
$argact = $ARGV[0] or die "No number given\n"; open INPUT, 'one.txt' or die $!; open NEWFILE, '>', 'output' or die $!; while (<INPUT>){ if(/^Authentication\s+number\s+is/) { my ($old_num) = /(\d+)/; if ($argact != $oldnum) { $changeflag = 1; s/\d+/$argact/; } } print NEWFILE; }
Note: I've included $changeflag only because it was in the original code. I've no idea what it's there for. Maybe its value is checked later on in the program.
Update: Typo fixed.
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: File modification
by Hofmator (Curate) on Jul 07, 2006 at 12:33 UTC | |
|
Re^2: File modification
by qsl (Scribe) on Jul 07, 2006 at 12:28 UTC | |
by davorg (Chancellor) on Jul 07, 2006 at 12:33 UTC |