[Mastering-perl] Perl Contexts & Symbol Tables and Typeglobs
Florian Merges
fmerges at cpan.org
Wed Jan 3 03:46:07 EST 2007
Hi again,
2007/1/3, brian d foy <brian.d.foy at gmail.com>:
>
> On 1/2/07, Florian Merges <fmerges at cpan.org> wrote:
> > Ch. Symbol Tables and Typeglobs
> > =========================
> >
> > Section: Package and lexical variables
> > --------------------------------------------------------
> >
> > $n and $global should be declared with 'our'
>
> I've never really been fond of our as a way to declare variables. It's
> useful to bring a package variable into play when a lexical of the
> same name is in scope, but otherwise is just a trick to get around use
> strict. If I really want to make something global, I prefer to list
> them all in 'use vars' :)
Yeah, of course, use vars would be more clean...
However, for those examples I'm specifically avoiding our() until
> later so I don't hit the reader with everything at once.
>
>
> > The first code example, instead of using the 'foreach' idiom, I would
> suggest:
>
> > print join "\n", keys %main::;
>
> I could do that, I guess, but it really doesn't add anything to the
> discussion. In the later example where I check the definedness on the
> var types for each identifier I would have to go back to foreach(), so
> I might as use it in the same way in the preceding examples.
I was thinking about showing more ways to do things, but yes, I took a look
again to the later examples and you're expanding the foreach
>
> >
> > Section: Package and lexical variables -> Full package specification
> >
> --------------------------------------------------------------------------------------------------
> >
> > Last example output should be:
> >
> > In the naked block, our $global is --> I'm the global version
> > In lexical, my $global is --> I'm in the lexical version
> > The package version is still --> I'm the global version
> > In lexical(): I'm the global version
> >
> > Section: The symbol table
> > --------------------------------------
> >
> > The first code example, instead of using the 'foreach' idiom, I would
> > suggest:
> >
> > print join "\n", keys %main::;
> >
> > Section: The symbol table -> Naming anonymous subroutines
> >
> -----------------------------------------------------------------------------------------
> >
> > ..., and then using that function to created two anonymous subroutines.
> >
> > ==> what?
> >
> >
I'm doing a full review picking chapters randomnly, printing them to paper,
and so, but, do you need a review of a specific chapter?, or more
information, examples for a non finished one?
> Kind regards,
> >
> > Florian
> >
> >
> >
> >
> >
> > _______________________________________________
> > Mastering-perl mailing list
> > Mastering-perl at theperlreview.com
> > http://five.pairlist.net/mailman/listinfo/mastering-perl
> >
> >
> >
>
>
> --
> brian d foy <brian.d.foy at gmail.com>
> http://www.pair.com/~comdog/
> _______________________________________________
> Mastering-perl mailing list
> Mastering-perl at theperlreview.com
> http://five.pairlist.net/mailman/listinfo/mastering-perl
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://five.pairlist.net/pipermail/mastering-perl/attachments/20070103/e4ad7f93/attachment.htm
More information about the Mastering-perl
mailing list