On Mar 20, 2004, at 1:20 PM, JupiterHost.Net wrote:

Howdy List!

I noticed in the source code for the File::Slurp module that it does 'use strict;' and then in sub error {} it calls a function like so :
$func->($err_msg);


I was curious as to how that is possible without using "no strict 'subs';" or "refs" or something , and have it not cause an error of some kind?

In this case, $func holds a "hard reference", not a "soft reference". The strict pragma only blocks the latter.


Here's a simple example:

sub howdy { print "Howdy!\n"; }

my $func = \&howdy; # hard reference
$func->();           # fine, even with strictures

$func = 'howdy';                # soft reference, name only
$func->();           # will not pass strictures

Hope that helps.

James


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




Reply via email to