Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!ogicse!milton!newton!lgy From: lgy@phys.washington.edu (Laurence G. Yaffe) Newsgroups: comp.lang.perl Subject: Signal handlers, scoping & control confusion Message-ID: Date: 6 Mar 91 21:38:00 GMT Sender: news@milton.u.washington.edu Lines: 40 After reading 'the Book' & scanning the man page, I'm still confused about signal handlers & scoping rules for things like statement labels & subroutine names. As an example, consider a structure like: { loop: foreach $file (...) { $SIG {'INT'} = 'interrupt' ; &compare (...) ; sub interrupt { last loop if (...) ; } } return; } sub compare { if (...) { &interrupt ;} } (a) The 'last loop' statement inside the handler 'interrupt' does seem to work. If I omit the statement label on the 'last' statement inside the handler, then perl occasionally dumps core (this is at PL37). Should a label-less 'last', 'redo', etc. statement inside a nested subroutine work? Even if the subroutine is a signal handler? What determines if a statement label is in scope - lexical (static) scoping or dynamic scoping? (b) Calling the 'interrupt' from within the 'compare' routine works. Should it? Although this is very convenient for my purposes, I would have expected 'interrupt' not to be in scope within the 'compare' routine. -- -------------------------------------------------------------------------- Laurence G. Yaffe Internet: lgy@newton.phys.washington.edu University of Washington Bitnet: yaffe@uwaphast.bitnet