#!/usr/bin/perl -w use strict; use warnings; use FileHandle; (my $argact = shift) or die "Syntax: $0 \n"; my $input = new FileHandle; my $newfile = new FileHandle; open($input, "<", "one.txt") or die "Failed to read 'one.txt' ($!)\n"; open($newfile, ">", "output") or die "Failed to write 'output' ($!)\n"; while(<$input>){ s/^Authentication\s+number\s+is\s+(\d+)/Authentication number is $argact/; print $newfile "$_"; } close $input; close $newfile;