Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: recursively passing hash reference

by thealienz1 (Pilgrim)
on Apr 03, 2006 at 07:49 UTC ( #540874=note: print w/replies, xml ) Need Help??


in reply to recursively passing hash reference

Alright, just an update. I believe I have found the problem.

use strict; use Data::Dumper; my $start = {}; sub add{ my $root = shift; my $level = shift; my @items = @_; if(!@items) {return $level-1;} #print "level = $level\n"; while(@items) { my $first = shift @items; $root->{$first}->{count}++; if(!exists($root->{$first}->{children})) {$root->{$first}->{ch +ildren}={};} #print "\t" x $level . "first = " . $first . ", values = " . j +oin(',',@items)."\n"; $root->{$first}->{max} = add($root->{$first}->{children}, $lev +el+1, @items); } } add($start, 1, 1..4); add($start, 1, 1..2); print Dumper($start);

I was passing hash reference that were undefined, which is not a good thing apparently. So, I fixed that problem.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2019-10-19 06:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?