in reply to Win32/Linux portability

My guess is that $output contains a "\r" at the end.

#! /usr/bin/perl $somenum=5; $output="text.txt\r"; $output2="text.txt"; print " $somenum means that, $output has info.\n"; print " $somenum means that, $output2 has info.\n"; #OUTPUT # has info.s that, text.txt # 5 means that, text.txt has info.

Without more context I can't provide more help.

To get rid of a carriage return you can:

$output =~ s/\r//g;

Update: The OP changed the post so most of the info is out of context. The last remark should answer the current question.

Replies are listed 'Best First'.
Re^2: Win32/Linux portability
by ww (Archbishop) on Aug 06, 2011 at 18:43 UTC
    Original content (with tags cleaned up; no other changes):

    Hi all,

    I have a question:

    When I try to use a coed line like

    print "  $somenumber means that, $output has info.\n";

    I get different screen outputs in Windows and Linux (tried different shells).

    In windows it looks like it's supposed to be, which is:

    3 means that, text.txt has info.

    But under Linux it looks like this:

    has info.hat, text.txt

    So it looks like it goes back to the start of the line and overwrites the first part of the string after a variable is supposed to be printed. Why is that?

    ---------------------------------

    ww observes that the output shown does not support the supposition of the OP (immediately above)... BASED on the info supplied.

    OP: This is why we urge that you post sufficient code to reproduce the problem; at least a snippet of sample data; error messages (verbatim) if any; and (the only one you gave us) how the output fails to satisfy your expectations/desires. Please see:

    And please do not delete content you've posted. Use <strike>...</strike> if you must delete something, and mark updates with notice thereof....like this:

    Update: Added matter below the dashes; then reupdated to fix typos and markup.