I humbly appeal to the perl gurus for a "bless"ing.  Here is some sample
code:

sub ref_print_number($) {
        (my $name) = @_;
        return sub { 
                (my $foo) = @_;
                print "I was told to print number $foo by $name\n";
        };
}

The following works:
#input
8: $foo->{'alice'} = ref_print_number('alice');
9: $foo->{'alice'}(16);
#output
I was told to print number 16 by alice

The following does not:
#input
8: $foo->{'bob'} = ref_print_number('bob');
9: $foo->bob(16);
#output
Can't call method "bob" on unblessed reference at ./rt.pl line 9

Nor does:
#input
8: $foo->carol = ref_print_number('carol');
9: $foo->carol(16);
#output
Can't call method "carol" on unblessed reference at ./rt.pl line 8

So how exactly do I "bless" my methods?  Do I need to construct the
method differently?  Do I need to convince my boss that he really should
learn Python so I can write programs like this in it?

-- 
Soren Harward
[EMAIL PROTECTED]

____________________
BYU Unix Users Group 
http://uug.byu.edu/ 
___________________________________________________________________
List Info: http://phantom.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to