Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: print Is Substituting Characters At Beginning Of String

by Corion (Patriarch)
on Jan 14, 2016 at 19:18 UTC ( [id://1152798]=note: print w/replies, xml ) Need Help??


in reply to print Is Substituting Characters At Beginning Of String

chomp $line;

You still have the carriage returns (\r) at the end of your strings, which will move the cursor to the start of the line again and then overwrite stuff.

I recommend stripping all whitespace from the end of the strings:

$line =~ s!\s*$!!;

Replies are listed 'Best First'.
Re^2: print Is Substituting Characters At Beginning Of String
by shilo (Novice) on Jan 14, 2016 at 20:04 UTC

    Perfect! That was exactly it. Thank you!

      Hello shilo,

      As an aid to debugging, you can configure Data::Dumper to print whitespace characters (other than spaces) as backslash sequences by setting the $Data::Dumper::Useqq configuration variable:

      18:58 >perl -MData::Dumper -wE "my $s = qq[\tabc\r\n]; print Dumper($s +); $Data::Dumper::Useqq = 1; print Dumper($s);" $VAR1 = ' abc '; $VAR1 = "\tabc\r\n"; 18:58 >

      But I generally prefer Data::Dump, which does this by default:

      18:58 >perl -MData::Dump -wE "my $s = qq[\tabc\r\n]; dd $s;" "\tabc\r\n" 19:00 >

      Hope that helps,

      Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

        I am definitely going dig into this a little deeper. It seems strange that the CR characters left at the end of the lines read from the $input_fh filehandle are getting hung up on STDOUT, or print()'s ability to print to STDOUT...

        thanks,

        david...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1152798]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-24 23:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found