Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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
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!
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 = $_;

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 scrutinizing the Monastery: (9)
As of 2014-09-17 21:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (99 votes), past polls