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
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |