Mr. Shawn H. Corey пишет:
On Tue, 2008-09-30 at 17:30 +0300, Vyacheslav Karamov wrote:
Hi All!

I need to pass object to a function. How can I do it?

How to make this code work?

use Tree::Simple;


sub SomeFunc
{
    my $node = @_;
    foreach my $child ($node->getAllChildren() )
    {
       ...
    }
}
my $tree = Tree::Simple->new("tree", Tree::Simple->ROOT);

SomeFunc( $tree );




$tree contains a reference to an object of type Tree::Simple.  Like any
reference you can pass it around as you please.

To see what's inside $tree, use Data::Dumper

use Data::Dumper;
print '$tree : ', Dumper $tree;


I've made a mistake. Correct code:

sub SomeFunc
{
   my $node = shift @_;
   foreach my $child ($node->getAllChildren() )
   {
      ...
   }
}



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to