$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
In reply to Re: File modification
by davorg
in thread File modification
by madtoperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |