Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Joining an array

by trizen (Hermit)
on Feb 12, 2012 at 01:56 UTC ( #953272=note: print w/replies, xml ) Need Help??


in reply to Re: Joining an array
in thread Joining an array

A faster way:
my @array = qw(name John number 7 status unknown); my $i = -2; my $x = $#array - 1; my $str = ''; while (1) { if ($i + 3 < $x) { $str .= $array[$i += 2] . '=' . $array[$i + 1] . '&'; } else { $str .= $i + 3 == $x ? $array[-3] . '=' . $array[-2] . '&' . $arra +y[-1] : $i + 2 == $x ? $array[-2] . '=' . $array[-1] : $array[-1]; last; } } print "$str\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://953272]
help
Chatterbox?
and the voices are still...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2016-12-02 22:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (51 votes). Check out past polls.