in reply to Re: perl -mstrict foo.pl
in thread perl -mstrict foo.pl

Yes, thank you, you've all understood my question right. There must be something else going on ... something fishy ... something embarrassing ...

alexf@localhost ~ $ perl -Mstrict -e 'print $a' alexf@localhost ~ $

Doubly embarrassing, looking back to Feb 2002, I once advised a soul facing exactly this puzzler.

Yours, sheepishly
ViceRaid

Replies are listed 'Best First'.
Re: Re: Re: perl -mstrict foo.pl
by Tomte (Priest) on Jun 06, 2003 at 16:46 UTC

    Update: realized too late that you understood the reason, nevertheless may this answer stand here for others as slow as myself in understanding written english :)

    perldoc perlvar :)

    $a $b Special package variables when using sort(), see "sort" in perlfunc. Because of this specialness $a and $b don't need to be declared (using local(), use vars, or our()) even when using the strict vars pragma. Don't lexicalize them with "my $a" or "my $b" if you want to be able to use them in the sort() comparison block or function.

    regards,
    tomte


    Hlade's Law:

    If you have a difficult task, give it to a lazy person --
    they will find an easier way to do it.

Re: Re: Re: perl -mstrict foo.pl
by djantzen (Priest) on Jun 06, 2003 at 17:24 UTC

    Oh, ha! $a and $b are global variables used by sort and so are already known by perl. That's why you don't see any errors in your example.


    "The dead do not recognize context" -- Kai, Lexx