T
toomanyjoes
Hello I'm trying to edit a text file and after my script finishes save
that text file. One thing I need to do is save the character AFTER a
match into a variable.
while (<FILE>){
s/<(Ra|N\d)>//;
s!^(.\w\w)( \d+)\d+)!$1~$2~$3!;
if (/<nsup>/)
# Then save the character
I've tried using the $POSTMATCH variable but it grabs the rest of the
line, I only want one character.
Also after I execute my replacements how do I save the changes to the
text file?
while (<FILE>){
s/<(Ra|N\d)>//;
s!^(.\w\w)( \d+)\d+)!$1~$2~$3!;
}
#save the changes made??
close FILE
Thanks,
Joe
BTW I finally got the correct syntax to open a file!
#!/usr/local/bin/perl -w
use warnings;
use strict;
open FILE, '<', 'C:\gen.txt' or die "Could not open file. $!";
while (<FILE>){
s/<(Ra|N\d)>//;
s!^(.\w\w)( \d+)\d+)!$1~$2~$3!;
print;
}
close FILE;
Thanks Guys!
that text file. One thing I need to do is save the character AFTER a
match into a variable.
while (<FILE>){
s/<(Ra|N\d)>//;
s!^(.\w\w)( \d+)\d+)!$1~$2~$3!;
if (/<nsup>/)
# Then save the character
I've tried using the $POSTMATCH variable but it grabs the rest of the
line, I only want one character.
Also after I execute my replacements how do I save the changes to the
text file?
while (<FILE>){
s/<(Ra|N\d)>//;
s!^(.\w\w)( \d+)\d+)!$1~$2~$3!;
}
#save the changes made??
close FILE
Thanks,
Joe
BTW I finally got the correct syntax to open a file!
#!/usr/local/bin/perl -w
use warnings;
use strict;
open FILE, '<', 'C:\gen.txt' or die "Could not open file. $!";
while (<FILE>){
s/<(Ra|N\d)>//;
s!^(.\w\w)( \d+)\d+)!$1~$2~$3!;
print;
}
close FILE;
Thanks Guys!