some puzzles

Roxanne Reid-Bennett rox at tara-lu.com
Tue Mar 20 15:55:47 CST 2001


Michael Fowler wrote:
> >
> > However, running this through the Activestate debugger, it does in fact
> > run through the callsub 3 times before executing the $num = 10.
> 
> Perl doesn't have scoped named subroutines, the sub in the block is a bit
> misleading (and probably part of the source of his confusion).  When perl
> sees a named subroutine declaration the subroutine is available almost
> anywhere.  The only place it wouldn't be available is in code being

aha, ok.

it didn't help that I read the following:

> my $count = 0;
> callsub() while ($count++ < 3);
> {
...
> }

as (re-arranged a little bit to make my point)

> my $count = 0;
> callsub();
> while ($count++ < 3)
> {
...
> }

Makes a bit of a difference [and teaches me once again to read the code as the
compiler does, not just read what I'm seeing and make allowances for other
people's formatting ...]

I had also totally forgotten the distinction between arrays and lists. 

Thanks Michael.

Rox
-- 
Roxanne Reid-Bennett                       rox at tara-lu.com
President, Tara-Lu Corporation     http://www.tara-lu.com/

Quality brings its own reward.
=================================================
Mailing list info:  If at any time you wish to (un|re)subscribe to
the list send the request to majordomo at hfb.pm.org.  All requests
should be in the body, and look like such
                  subscribe anchorage-pm-list
                  unsubscribe anchorage-pm-list



More information about the Anchorage-pm mailing list