Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: split every other value

by qq (Hermit)
on Aug 07, 2004 at 13:30 UTC ( [id://380901]=note: print w/replies, xml ) Need Help??


in reply to split every other value

nothing fancy:

#!/usr/bin/perl my @array = ( a .. x, undef ); print "@array\n"; my (@a,@b); for ( 0 .. $#array ) { if ( $_ % 2 ) { push @b, $array[$_]; } else { push @a, $array[$_]; } } print "a: '@a'\n"; print "b: '@b'\n";

qq

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-19 14:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found