Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

how to push single array?

by virudinesh (Acolyte)
on May 13, 2013 at 09:02 UTC ( [id://1033269]=perlquestion: print w/replies, xml ) Need Help??

virudinesh has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: how to push single array?
by Anonymous Monk on May 13, 2013 at 09:11 UTC

    Please use more words when asking a question, and describe what you want to happen, and how its different from what it happens

    As your question is written I cannot determine what you're asking

    So I offer you this (dd does printing)
    codeoutput
    #!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd /; my @feet = qw/ left right /; my @shoes = qw/ loader sneaker boot /; my @things; dd { feet => \@feet, shoes => \@shoes, things => \@_ }; push @shoes, qw/ slippers /; dd { feet => \@feet, shoes => \@shoes, things => \@_ }; push @things, \@feet, \@shoes; dd { feet => \@feet, shoes => \@shoes, things => \@_ };
    { feet => ["left", "right"], shoes => ["loader", "sneaker", "boot"], things => [], } { feet => ["left", "right"], shoes => ["loader", "sneaker", "boot", "slippers"], things => [], } { feet => ["left", "right"], shoes => ["loader", "sneaker", "boot", "slippers"], things => [], }

    Also please read perlintro and use Basic debugging checklist (among others)

      haha, what the heck is a "loader" shoe? typos fixed
      codeoutput
      #!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd /; # sub dd { use Data::Dumper; print Data::Dump +er->new([@_])->Sortkeys(1)->Indent(1)->Useqq(1)->Dump . "\n"; } my @feet = qw/ left right /; my @shoes = qw/ loader sneaker boot /; my @things; dd { feet => \@feet, shoes => \@shoes, things => \@things }; push @shoes, qw/ slippers /; dd { feet => \@feet, shoes => \@shoes, things => \@things }; push @things, \@feet, \@shoes; dd { feet => \@feet, shoes => \@shoes, things => \@things };
      { feet => ["left", "right"], shoes => ["loader", "sneaker", "boot"], things => [], } { feet => ["left", "right"], shoes => ["loader", "sneaker", "boot", "slippers"], things => [], } do { my $a = { feet => ["left", "right"], shoes => ["loader", "sneaker", "boot", "slippers"], things => ['fix', 'fix'], }; $a->{things}[0] = $a->{feet}; $a->{things}[1] = $a->{shoes}; $a; }
        "loader" -> "forklift" -> "high heels"?

Log In?
Username:
Password:

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

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

    No recent polls found