in reply to Concat strings from parameter file

wf_BMRK*.outg concatenation: rm -f /ontw/log/powercenter8/PRJ10/

Looks like there is a carriage return (\r) at the end of the string in $env_hash{$os}{LOGDIR} (i.e. "/ontw/log/powercenter8/PRJ10/\r") , which makes the terminal's cursor move to the beginning of the line...  (To verify, redirect the output to a file and then hexdump its contents.)

Replies are listed 'Best First'.
Re^2: Concat strings from parameter file
by jevaly (Sexton) on Dec 08, 2009 at 09:46 UTC

    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?
      ...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.

      chomp() will remove only trailing string that corresponds to the current value of $/ ($INPUT_RECORD_SEPARATOR).
      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