Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^5: Troubles with Unshift and Push

by vinoth.ree (Monsignor)
on Mar 04, 2015 at 05:31 UTC ( [id://1118709]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Troubles with Unshift and Push
in thread Troubles with Unshift and Push

Sorry, I'm new to Perl and I don't know what you're saying

Reading this node Arrays: A Tutorial/Reference will help you better learning.

Here is the code I did some changes in your code try and let me know.

use strict; use warnings; use Data::Dumper; my @num_weights = (36,264,188); my @leftovers = (1,2,3,4); my @hold_generations; my $i = 0; for(my $p = 0; $p < 1;$p++) #Go through all leftovers { my $pick = $leftovers[$p]; unshift @num_weights, $pick; #add item print Dumper(\@num_weights); push @hold_generations, @num_weights; #store new array print Dumper(\@hold_generations); splice @num_weights, 1, 1; #undo adding item print Dumper(\@num_weights); }

Note:

I do not have features module so I just used print()


All is well. I learn by answering your questions...

Replies are listed 'Best First'.
Re^6: Troubles with Unshift and Push
by nat47 (Sexton) on Mar 04, 2015 at 05:37 UTC
    This worked perfectly! I'm looking over it now to try and see the differences. Thank you so much.

    I've actually been referencing that today :crying face:

    EDIT: I'm confused... it looks exactly the same? EDIT2: () vs []? I feel like a moron.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-18 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found