Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: print last array element without a new line

by onegative (Scribe)
on Oct 19, 2011 at 20:14 UTC ( [id://932492]=note: print w/replies, xml ) Need Help??


in reply to Re^2: print last array element without a new line
in thread print last array element without a new line

Look at http://www.perlmonks.org/?node_id=791664
  • Comment on Re^3: print last array element without a new line

Replies are listed 'Best First'.
Re^4: print last array element without a new line
by ikegami (Patriarch) on Oct 19, 2011 at 23:02 UTC

    That means you had a carriage return in the middle of the line.

    A better solution would be to change

    chomp(my $record = $_);
    to
    s/\r?\n//; my $record = $_;
    or even
    s/\s+\z//; my $record = $_;
Re^4: print last array element without a new line
by sy (Initiate) on Oct 19, 2011 at 21:05 UTC
    Thank you kindly! That was it. One of my files was from a distinct source (CSV export from Apple Numbers) and hence had a different line separator. Changing the local definition of $/ fixed the problem. Thanks so much for your help!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-19 19:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found