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

Re: Virus toy model

by toolic (Bishop)
on Jun 30, 2011 at 00:52 UTC ( #912065=note: print w/replies, xml ) Need Help??


in reply to Virus toy model^2

There is something wrong with the way I am passing the arrays to the hash .. it will output ie ARRAY(0x1f512580), not sure where exactly the problem is.
You need to deference the array. Change:
my @last_gen=$allgen{$i-1};
to:
my @last_gen=@{$allgen{$i-1}};
perldsc

Replies are listed 'Best First'.
Re^2: Virus toy model
by Anonymous Monk on Jun 30, 2011 at 05:08 UTC
    Thankyou dearly. I spent way too much time trying to figure that out! Also why is it that %hash=(0=>A) must be followed by $hash{1}=B ( for next key value pair you set I mean. ) rather than using the first format twice? I can't find this anywhere in the camel book or online.

      I guess you are asking why you can't do this:

      %hash=(0=>A); %hash=(1=>B);

      Both these operations operate on the whole hash, initializing it with the data on the right side of the equation. The equation sign "=" means literally "the left side is made equal to the right side", not "the right side is added to or combined with the left side". So after the second equation any previous values in the hash will be lost

      While when you use $hash{1}=B you only manipulate one value inside the hash, leaving the rest of the hash unchanged.

      Thankyou dearly. I spent way too much time trying to figure that out! Also why is it that %hash=(0=>A) must be followed by $hash{1}=B ( for next key value pair you set I mean. ) rather than using the first format twice? I can't find this anywhere in the camel book or online.

      It does not have to be followed. This is covered in perlintro under Perl variable types, or if you're new to programming, http://learn.perl.org/books/beginning-perl/

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (1)
As of 2022-01-27 05:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (70 votes). Check out past polls.

    Notices?