Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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: (4)
As of 2016-06-25 11:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (325 votes). Check out past polls.