On Tuesday 24 February 2004 04:29, Michael Ragsdale generously enriched virtual reality by making up this one:
.. > >However, dont pass the object - pass a refernece to it in line 2, like: > >my $go = $right->Button(-text=>'Get Data',-command=>sub{compute(\ > >$ent)})->pack(-side=>'top'); > > > >and use $$_[0]->get in compute > > I see the advantages of passing by reference, however, when I added the \ > to pass the reference of $ent and the $ to dereference $_[0], it no longer > worked. These were the only two changes and it left me with... > > my $go = $right->Button(-command=>sub{compute(\$ent)})->pack; > > sub compute{ > my $input = $$_[0]->get(); > $sth->execute($input) or die..... > } > > The error was "can't call method get on an undefined value". Now I'm > really confused. Why would passing the object work, but passing the > reference and then dereferencing in the sub doesn't? my fault: my $input = ${$_[0]}->get(); should work. I usually use something like : my $passed_ref=shift; and then work from there on. Enjoy: wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>