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

Re^2: Printing Last Element of a line using perl memory?

by jaredor (Curate)
on Feb 15, 2013 at 18:12 UTC ( #1018937=note: print w/replies, xml ) Need Help??


in reply to Re: Printing Last Element of a line using perl memory?
in thread Printing Last Element of a line using perl memory?

++ for the END block idea. A further tweak would be to not process data in the main loop, but only the END block. Unfortunately I could not think of a slick way to make $_ available to END from the last loop iteration, so I had to cheat a little to golf your solution. Apparently the autosplit array does remain resident:

perl -nae 'END { print "$F[-1]\n"; }' scan.log

Good examples like yours are weaning me from sed ;-)

Replies are listed 'Best First'.
Re^3: Printing Last Element of a line using perl memory?
by pemungkah (Priest) on Mar 11, 2013 at 20:02 UTC
    Ooh, nice! I'll use that one too.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1018937]
help
Chatterbox?
[Discipulus]: create an account for him; we are funny baby sitters ;=) come here child, want to listen the typeglob tale?
[vrk]: choroba Oh, that's good.
[vrk]: Discipulus I don't know much about prime numbers, but wouldn't that kind of an answer be in a graduate-level number theory book?
[Discipulus]: my 8 yo daughter has two weeks of sleep disturbs.. we are gonna be crazy..
[Discipulus]: vrk i searched but found nothing: after this my math level if terribly low but i like to discuss my discovery with kind mathematicians

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2017-04-27 08:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (501 votes). Check out past polls.