in reply to Substitute script for a newbie
$line =~ s/A.TL5F00/+TL\\F5C/g;
Tip #1 from the Basic debugging checklist: diagnostics might give you a little more info (it didn't for me on Perl version 5.12, but it did for 5.14).
Did you really want the print inside the while loop? while ( $line = <FILE> ) { is really the same as while (defined($line = <FILE>)) {. So, outside the while, $line is undefined.
UPDATE: You can simplify the if/else code with this single substitution:
use warnings; use strict; while (my $line = <DATA>) { $line =~ s/^A.TL5([EF])00/+TL\\${1}5C/g; print $line; } __DATA__ A.TL5E001100.TAV A.TL5F001100.TAV
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Substitute script for a newbie
by jspanos (Initiate) on Jul 14, 2015 at 17:14 UTC | |
by Laurent_R (Canon) on Jul 14, 2015 at 17:52 UTC | |
by jspanos (Initiate) on Jul 14, 2015 at 18:44 UTC | |
by Laurent_R (Canon) on Jul 14, 2015 at 18:55 UTC | |
by jspanos (Initiate) on Jul 14, 2015 at 19:42 UTC | |
|