in reply to No effect with SIG{INT}

Now I have the problem that SIG{INT} = \&close() is executed at the beginning of the program. I'm using an object now, so when Ctrl-C is pressed this object has to be closed properly, like:
#main $obj = DBConnect->new ; $SIG{INT} = \&close ; .... .... sub close { $obj->close ; exit ; }
Any suggestions why this is wrong ?

Luca

Replies are listed 'Best First'.
Re^2: No effect with SIG{INT}
by borisz (Canon) on Jan 16, 2006 at 13:38 UTC
    your example work. And close is NOT called. I guess you wrote $SIG{INT} = \&close(); that line call close. You want $SIG{INT} = \&close.
    $SIG{INT} = \&close(); # wrong $SIG{INT} = \&close; # ok
    Boris
Re^2: No effect with SIG{INT}
by ysth (Canon) on Jan 17, 2006 at 01:18 UTC
    To amplify on what borisz said, \&close() is a reference to the value returned by close(), while \&close is a reference to sub close (which need not have already been defined).