in reply to Re^3: Substitute script for a newbie
in thread Substitute script for a newbie
The file I have is only the old symbols and it is a list of 590; like below (minus the spaces)
A.TL5E001100.TAV
A.TL5F001560.TAV
A.TL5T001240.TAV
A.TL5E001230.TAV
A.TL5E001270.TAV
So A.TL5E001100.TAV needs to change to +TL\E5C1100.TAV, A.TL5F001560.TAV needs to change to +TL\F5C1560.TAV, etc
I rewrote the code to be a lot simpler and only did one substitution just so I could see what the output is. Now it runs, but I get no output so I need to read up on matching and substitution string syntax.
use strict; use warnings; my $input = 'TAV.stock.opt.oldsym.txt'; { unless(open(INPUT,$input)) { die "\nCannot open $input\n"; } <INPUT>; my @lines; while(my $line = <INPUT>) { chomp $line; if ($line =~ m/^A.TL5E00/) { $line =~ s/A.TL5E00/'+TL\E5C'/g; } } close INPUT; foreach my $line(@lines) { print $line,"\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Substitute script for a newbie
by Laurent_R (Canon) on Jul 14, 2015 at 18:55 UTC | |
by jspanos (Initiate) on Jul 14, 2015 at 19:42 UTC | |
by Laurent_R (Canon) on Jul 14, 2015 at 20:07 UTC |