Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

by onegative (Scribe)
on Oct 19, 2011 at 20:14 UTC ( #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 (Pope) 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
Node Status?
node history
Node Type: note [id://932492]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2015-07-08 05:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (94 votes), past polls