in reply to Re^6: Substitute script for a newbie
in thread Substitute script for a newbie
might probably be rewritten in a simpler fashion:if ($line =~ m/^A.TL5E00/) { $line =~ s/A.TL5E00/+TL\E5C/g; push @NewSym,$line; }
I haven't tested it on real data (you did not supply any), but it seems to work properly, as shown in this session under the Perl debugger:push @NewSym, $line if $line =~ s/^A.TL5E00/+TL\E5C/g;
If the substitution does not find a match, it will report a false value and the push will not be executed.$ perl -de 42 Loading DB routines from perl5db.pl version 1.33 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 42 DB<1> $line = "A.TL5E00xxxx"; DB<2> push @NewSym, $line if $line =~ s/^A.TL5E00/+TL\E5C/g; DB<3> x @NewSym 0 '+TL5Cxxxx'
|
|---|