in reply to Re: Scoping question
in thread Scoping question

As a matter of fact, this even does not work:

use strict; use warnings; my $item = $item;

You will get:

Global symbol "$item" requires explicit package name at a.pl line 4. Execution of a.pl aborted due to compilation errors.

Update:

see bpphillips's reply to my post, duff could actually meant what dpphillips detailed below.

Replies are listed 'Best First'.
Re^3: Scoping question
by bpphillips (Friar) on Nov 03, 2004 at 21:17 UTC
    I think your interpretation of duff's example is different than intended. Consider:
    use strict; use warnings; my $item = "a"; if(1){ my $item = $item; }
    This compiles fine with no errors...

      Note that you don't need to have if (1). A block is fine all by itself, and does enforce a new scope. A bare block is a loop construct though while an if block isn't, which is important to remember when you use e.g. last.

      ihb

      See perltoc if you don't know which perldoc to read!
      Read argumentation in its context!