James Edward Gray II wrote:
> 
> On Wednesday, June 11, 2003, at 05:27  PM, James Edward Gray II wrote:
> 
> > I'm setting the warning signal ($SIG{__WARN__}) to my own handler,
> > redirecting warnings to my log file.  It is working.  I can see the
> > call come through, but the passed @_ is completely empty.  Shouldn't I
> > be able to get the warning message out of there?  Thanks for any
> > insights.
> 
> Sorry to reply to my own message, but I've figured out what's wrong and
> now I'm even more confused.  I was doing:
> 
> $SIG{__WARN__} = \&my_warn();
                            ^^
Lose the parenthesis and it should work.

$ perl -le'
sub my_warn { print STDERR "warn sub @_" }
$SIG{__WARN__} = \&my_warn();
warn " HI ";
'
warn sub 
Not a subroutine reference at -e line 4.
$ perl -le'
sub my_warn { print STDERR "warn sub @_" }
$SIG{__WARN__} = \&my_warn;
warn " HI ";
'
warn sub  HI  at -e line 4.


> When I changed it to the following, it started working:
> 
> $SIG{__WARN__} = sub { HANDLE WARN CODE HERE };
> 
> Can someone please explain the difference between the two assignments
> to me?  Thanks again.

When you use the parenthesis perl calls the sub and in this context
expects the return value to be a reference to a subroutine.


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to