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?