Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: recursively passing hash reference

by thealienz1 (Pilgrim)
on Apr 03, 2006 at 07:49 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://540874]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-20 01:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found