LloydRice has asked for the wisdom of the Perl Monks concerning the following question:
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 substringuse 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;
in the original became((100% - 278px)/2)
in the copy. where((100789f78<- 270 spaces ->x)/2)
is a way of writing<- 270 spaces ->
The substring" " x 270
in the original became((100% - 206px)/2)
in the copy. where((100789f78<- 198 spaces ->x)/2)
is a way of writing<- 198 spaces ->
What happened?? Clearly, the percent character is suspicious. But when did it get its special meaning?" " x 198
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: string interpolation
by Eily (Monsignor) on Feb 10, 2017 at 12:29 UTC | |
by LloydRice (Beadle) on Feb 10, 2017 at 14:08 UTC | |
Re: string interpolation
by hippo (Archbishop) on Feb 10, 2017 at 12:25 UTC | |
by LloydRice (Beadle) on Feb 10, 2017 at 14:20 UTC | |
Re: string interpolation
by johngg (Canon) on Feb 10, 2017 at 12:03 UTC | |
by LloydRice (Beadle) on Feb 10, 2017 at 13:53 UTC |