perl script prints parts of strings in the wrong order

Olivier Olivier.Nicole at cs.ait.ac.th
Tue Aug 7 05:37:08 UTC 2018


"M. Fioretti" <mfioretti at nexaima.net> writes:

> hello,
>
> I am trying to reuse an old perl script I wrote years ago, on an Ubuntu 
> 16.-04LTS x86_64 box.
> It behaves in a very odd way now, and I cannot figure out if it is the 
> code that is not
> compatible with current versions of Perl, or if there is something VERY 
> strange happening
> between the script, and the terminal it runs in.
>
> The part of the script that works badly is this:
>
> while (<INPUTFILE>) {
>      chomp;
>      my $LINE = $_;
>      many lines that "clean up" $LINE, removing certain substrings etc...
>
>      @F = split /:/, $LINE;
>      print "CURL:==> $F[0] ++ $CURLRES{$F[0]} ;;\n";
> }
>
> when I run it, SOME of the printed lines (say 1 every 30) have the
> expected format:
>
> CURL:==> string_a ++ string_b ;;
>
> but all the others are like this:
>
>
>   ;;L:==> string_c ++ string_d ;;
>
> that is, the three initial "CUR" characters are replaced by " ;;"
>
> It's as if something had pasted the last three characters over the first 
> three ones.
>
> I have no idea what is going wrong, and why. Any help is appreciated,

A wild guess, but there may be something strange in the input file,
like some lines contain a \r.

I would manually check the input file and also try to print the
resulting $F[0] alone on a line:

print "--$LINE--\n";
print "++$F[0]++\n";

Olivier

>
> TIA,
>
> Marco
>
> -- 
> http://mfioretti.com

-- 




More information about the ubuntu-users mailing list