Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: counting number of fileds

by SuperCruncher (Pilgrim)
on Dec 09, 2002 at 20:10 UTC ( [id://218649]=note: print w/replies, xml ) Need Help??


in reply to counting number of fileds

First of all, it seems like you need to read up on Perl. Try some of the things suggested at the Learn Perl site.

split returns a list. You can store this list in an array, e.g. my @bits = split /,/, "foo,bar,baz";. In Perl, you can find out how many elements are in an array by doing scalar @array (or scalar @bits in this case). Subtract one to get the index of the last element. Anyway, you can get at the last three elements by doing: my (@last_three) = ($bits[-1], $bits[-2], $bits[-3]);

Hope this helps, but make sure you learn Perl properly. You'll thank yourself for it.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-19 02:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found