passing blessed thingies as parameters

Stray Toaster mwk at stray-toaster.co.uk
Fri Dec 28 02:08:36 CST 2001


On Thu, Dec 27, 2001 at 11:48:29PM +0000, Liyang Hu wrote:
> How? I'm not even sure what to look up for this. Say I wanted to do
> something like this:
> 
> 	use Mail::Audit;
> [0]	sub foo($)
> 	{
> 	    $ma = shift();
> 	    $ma->accept(...yada...);
> 	}
> 	$mail = new Mail::Audit;
> 	foo($mail);
> 
> perl barfs on the $ma = shift() line. Obviously sub foo doesn't even
> know what it was passed, so I don't think $ma->accept()'s going to
> work either.
> 
> Enlightenment, anyone?
> 
> /Liyang
> [0] The mailing list manager barfed upon seeing this line the last
> time I sent this.

err, not sure what the problem you are having here is, but I am mostly
thinking it is just the leaving off of an ampersand?? I hate coming up
with answers like this, as I am always wrong, and it is a
protyping-deep-in-perl-of-which-I-know-nothing answer actually. But
here, this works for me....

use CGI;

my $q = CGI->new;

&foo($q);

sub foo($) {
  my $thing = shift;
  print "\n\n $thing \n\n";
}

a tired, put upon up to early, awful Christmas experience m.

-- 
So they went off together. But wherever
they go, and whatever happens to them on the way,
in that enchanted place on the top of the Forest
a little boy and his Bear will always be playing.



More information about the Belfast-pm mailing list