in reply to Re: Concat strings from parameter file
in thread Concat strings from parameter file


When I look at the hexadecimal version of the parameter file there is indeed a carriage return ('0D').
However, I lived in the blissful ignorance that the chomp($temp) would spare me all the nasty newline problems. Apparently it doesn't?
  • Comment on Re^2: Concat strings from parameter file

Replies are listed 'Best First'.
Re^3: Concat strings from parameter file
by almut (Canon) on Dec 08, 2009 at 09:56 UTC
    ...that the chomp($temp) would spare me all the nasty newline problems

    Depends on what's in $/$/ by default holds "\n". On Windows, the :crlf PerlIO layer is responsible for translating "\r\n" to "\n". On Unix, this layer is not active (by default), so in case you have input coming from Windows (via cut-n-paste, or whatever), the carriage returns will survive.

Re^3: Concat strings from parameter file
by ph0enix (Friar) on Dec 08, 2009 at 09:57 UTC
    chomp() will remove only trailing string that corresponds to the current value of $/ ($INPUT_RECORD_SEPARATOR).
Re^3: Concat strings from parameter file
by roboticus (Chancellor) on Dec 08, 2009 at 15:43 UTC
    jevaly:

    Yep ... in the Windows world, things can be a bit messy. Many Windows users simply replace chomp $varname; with $varname =~ s/\s+$//; to trim off all trailing whitespace from a variable.

    NOTE: It's not an exact replacement, so if your code expects whitespace at the end of your lines, you'll probably want to adjust $/ to the proper value for your incoming files. For my purposes, removing whitespace from the end of the string works fine in nearly all cases.

    ...roboticus