Can anybody help me understand what's going on here? Apparently, string interpolation is happening at some point where I did not expect it. I have a file with about 30 very long lines. The lines range from 50,000 to 70,000 chars each. I wrote a small bit of Perl expecting to cut out some short strings near the beginning of each line, but to keep the rest of each line, writing the result back to a new file.
use strict; my $me = "read52"; # Perl script to check (and revise?) the long lines in file save52.dat my $file52 = "save52.dat"; my $newfile52 = "save52x.dat"; open( S52, "<$file52" ) or die "$me: Failure opening old long-lines file '$file52'.\n"; open( NS52, ">$newfile52" ) or die "$me: Failure opening new long-lines file '$newfile52'.\n"; while ( <S52> ) { chomp; my $new = substr( $_, 5, 9 ) . substr( $_, 53 ); print NS52 "$new\n"; } close S52; close NS52;
What happened surprised me. Apparently, interpolation occurred somewhere in the process of reading or writing the long lines. Here are two cases which I studied in detail. The substring
((100% - 278px)/2)
in the original became
((100789f78<- 270 spaces ->x)/2)
in the copy. where
<- 270 spaces ->
is a way of writing
" " x 270
The substring
((100% - 206px)/2)
in the original became
((100789f78<- 198 spaces ->x)/2)
in the copy. where
<- 198 spaces ->
is a way of writing
" " x 198
What happened?? Clearly, the percent character is suspicious. But when did it get its special meaning?

In reply to string interpolation by LloydRice

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.