Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Shifting of 2D array slices

by davidrw (Prior)
on Dec 07, 2008 at 01:22 UTC ( #728625=note: print w/replies, xml ) Need Help??

in reply to Shifting of 2D array slices

Besides the map solutions already posted, here's two others:
setup for both:
use Data::Dumper; my @bigarray = ( [ "123*jeff", "tortoise", "qwerty" ], [ "456*john", "parrot", "azerty" ], [ "789*jane", "budgie", "abcdef" ], ); print Dumper \@bigarray; # before ... print Dumper \@bigarray; # after
  • Using splice:
    splice @$_, 0, 1, split /\*/, $_->[0] for @bigarray;
  • Using shift and unshift:
    foreach my $arr ( @bigarray ){ my $item = shift @$arr; unshift @$arr, split /\*/, $item; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://728625]
[Discipulus]: which of 43 significance of NN?
[Discipulus]: NN?
[beech]: nobliest nodes
[Discipulus]: ah no newest nodes! ask something
[beech]: why is my butt itchy
Discipulus many countries without bidet.. is a big problem!

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2016-12-09 09:41 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (150 votes). Check out past polls.