Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Win32/Linux portability

by ikegami (Patriarch)
on Aug 03, 2011 at 18:18 UTC ( [id://918349]=note: print w/replies, xml ) Need Help??


in reply to Win32/Linux portability

chomp removes whatever you tell it to via $/.

But you might be better off just using s/\s+\z//; instead of chomp;. Note: It removes trailing space and other whitespace in the process. That's usually a good thing.

Replies are listed 'Best First'.
Re^2: Win32/Linux portability
by thelycaeum (Initiate) on Aug 06, 2011 at 14:51 UTC
    Thanks for your replies, I'm new to Perl so I'm not fit with that abbreviated syntax, e.g. "s/\s+\z//". I guess I'll stick with telling chomp how to handle arguments. I thought about something like:
    if (uc($^O)=~"WIN") {$/="\r\n"}

      I thought about something like:

      No need for that. See perlintro and use

      s/\r\n\z//; # or $line =~ s/\r\n\z//;
        It's been a year, but I still don't get that abbreviated syntax. For example, today I found out that I can easily split strings at each point using
        @foo=split(/\./,$bar);
        But to split at whitespace I can use
        @foo=split(" ",$bar);
        Why is that and what does it mean? I really don't get it, why doesn't
        @foo=split(".",$bar);
        work?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2024-03-19 02:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found