You are getting different results, because you are using strict & warnings -- neither of which are enabled in the original sample code in the book....

foreach $symname (sort keys %main::) { local *sym = $main::{$symname}; print "\$$symname is defined\n" if defined $sym; print "\@$symname is nonnull\n" if @sym; print "\%$symname is nonnull\n" if %sym; }
hossman@slate:~/tmp/9780596004927/programming_perl_examples [master] $ + perl -E "say $^V" v5.26.1
hossman@slate:~/tmp/9780596004927/programming_perl_examples [master] $ + perl ./program_listings/ch10/ch10.002.pl is defined $ is defined $" is defined $/ is defined $0 is defined $@ is defined %CORE:: is nonnull %DynaLoader:: is nonnull %ENV is nonnull @INC is nonnull %IO:: is nonnull %Internals:: is nonnull %PerlIO:: is nonnull %Regexp:: is nonnull %UNIVERSAL:: is nonnull %constant:: is nonnull %main:: is nonnull %mro:: is nonnull %re:: is nonnull $symname is defined %utf8:: is nonnull %version:: is nonnull
hossman@slate:~/tmp/9780596004927/programming_perl_examples [master] $ + perl -Mwarnings -Mstrict ./program_listings/ch10/ch10.002.pl Variable "$sym" is not imported at ./program_listings/ch10/ch10.002.pl + line 3. Variable "@sym" is not imported at ./program_listings/ch10/ch10.002.pl + line 4. Variable "%sym" is not imported at ./program_listings/ch10/ch10.002.pl + line 5. Global symbol "$symname" requires explicit package name (did you forge +t to declare "my $symname"?) at ./program_listings/ch10/ch10.002.pl l +ine 1. Global symbol "$symname" requires explicit package name (did you forge +t to declare "my $symname"?) at ./program_listings/ch10/ch10.002.pl l +ine 2. Global symbol "$symname" requires explicit package name (did you forge +t to declare "my $symname"?) at ./program_listings/ch10/ch10.002.pl l +ine 3. Global symbol "$sym" requires explicit package name (did you forget to + declare "my $sym"?) at ./program_listings/ch10/ch10.002.pl line 3. Global symbol "$symname" requires explicit package name (did you forge +t to declare "my $symname"?) at ./program_listings/ch10/ch10.002.pl l +ine 4. Global symbol "@sym" requires explicit package name (did you forget to + declare "my @sym"?) at ./program_listings/ch10/ch10.002.pl line 4. Global symbol "$symname" requires explicit package name (did you forge +t to declare "my $symname"?) at ./program_listings/ch10/ch10.002.pl l +ine 5. Global symbol "%sym" requires explicit package name (did you forget to + declare "my %sym"?) at ./program_listings/ch10/ch10.002.pl line 5. Execution of ./program_listings/ch10/ch10.002.pl aborted due to compil +ation errors.

In reply to Re^3: Interrogating stashes - Camel example doesn't work? by hossman
in thread Interrogating stashes - Camel example doesn't work? by Intrepid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.