Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Concat strings from parameter file

by jevaly (Sexton)
on Dec 08, 2009 at 09:46 UTC ( [id://811695]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-07-14 19:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.