http://qs321.pair.com?node_id=476594

drock has asked for the wisdom of the Perl Monks concerning the following question:

All, I need to search a file for a string then set a variable using substr b/c it is at a certain position, then finally replace the string with another string. Thank you, Here is my test code:
my $gpg=qq(/home/gpghrp/.gnupg); open (GPG, "gpg --fingerprint |") or die "unable to open pipe sys call + (1)... Broken? $!"; open(OLD,"+<$gpg/scripts/gpg_encr.saved") or die $!; open(NEW, "+<$gpg/scripts/gpg_encr.saved.new") or die $! for (;<OLD>;) { if ( /(?)readonly tlx=/ ) { my $ns =substr($_,13,8) print "Now substituting\n"; print NEW s/$ns/"blah"/; } } close (GPG); close (SYS);