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.
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 "$_\n";
print "$ns\n";
print "Now substituting\n";
print NEW s/$ns/"blah"/;
}
}
close (GPG);
close (SYS);
__END__CODE__
__BEGIN__DATA__
#PUBLIC KEYS
readonly an=809D16DD # Anthem's Key
readonly af=2ADCCA83 # Aflac's Key
readonly cb=79A05028 # Cenben's Key
readonly ci=FB0E9610 # CitiStreet's key
readonly co=DBBFAB1C # Concierge's key
readonly daw=CB0E1CA5 # Dawson's key
readonly df=935A53B4 # Definity's key
readonly dl=D357304B # Delta's Key
readonly flxb=31412625 # Flexbank's key
readonly fp=57931F1E # Fireproof's key
readonly hnb=E8D02D63 # Huntington's key
# EF2AA234 32BCF762 # HealthStream's keys. Set up as a
group
readonly hum=9564F2E1 # Humamarc's key --- non psoft
readonly ohg=D334EB59 # OhioHealth Group's key
readonly merc=0D3C3955 # Mercer's key
readonly ncb=165AAEBD # National City's key
readonly prvd=2EC1720B # UnumProvident's key
readonly tlx=886EC5AB # TALX's key
readonly vsp=03844E3A # VSP's key
readonly ws=68F0D515 # Workscape's key
The coobook CD give an example but not with a substr.
In both files the position od $ns will always be the same.
thank you,
derek
Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>