annel has asked for the wisdom of the Perl Monks concerning the following question:
Text: $ NAME : corry $$.Inc s d $$.Oc s $$.TO G1 ty n1 EE EE M T1 T2 $$SRU G2 n1 y OO OO M T3 T4 $$SRU .EON $ NAME : patrick $$.Inc c d $$.Oc c $$.TO G1 td n3 EE EE M T5 T6 $$SRU G2 n3 y OO OO M T7 T8 $$SRU .EON $ NAME : sandy $$.Inc k l $$.Oc l $$.TO G1 td n3 FF FF M R5 R6 $$SRU G2 n3 y OO OO N R7 R8 $$SRU .EON
Code: use strict; use warnings; open my $F1, '<', 'testing.txt' or die "failed $!"; open my $F2, '>', 'out.txt' or die "failed $!"; while (<$F1>) { if (/^\$ NAME : sandy/../\$.TO/) { print $F2 $_; } if (/^\$ NAME : patrick/../\$.EON/) { if(/^G1/../\$SRU){ s/G1/G1.G1o.n/g; print $F2 $_;} } } close $F1; close $F2;
|
|---|