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"; } }

In reply to Re^4: Substitute script for a newbie by jspanos
in thread Substitute script for a newbie by jspanos

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.