Re: keys %::
by dave_the_m (Monsignor) on Apr 29, 2005 at 10:19 UTC
|
what are the lowercase qw/stderr stdin stdout/ for
They're deprecated aliases for STDERR etc.
What do the _<-ones mean
They're for the debugger; see perldebguts.pod for the gory details
precisely when and where the destructor is used
No idea, but the destructor itself is a NOOP.
Dave.
| [reply] |
Re: keys %::
by Animator (Hermit) on Apr 29, 2005 at 11:51 UTC
|
A better subject would be something similar to: 'Symbol table of the main-package'...
Update: I should have know that mentioning that %:: is the symbol table of the package main and that it therefor is a better title would get downvoted....
Noone cares how it is called right?
Now I really wonder why I stopped posting a few months ago...
| [reply] |
|
|
Update: I should have know that mentioning that %:: is the symbol table of the package main and that it therefor is a better title would get downvoted....
Noone cares how it is called right?
FWIW it wasn't me to downvote you, if not for anything else because I don't have votes left for today...
I think you got downvoted because you only made a cmt about the subject with no positive content re the actual question. I say so because something similar happened to me in the past. We may both dislike this kind of things but this is a community after all, so we have to accept its rules if we like to take part to it...
| [reply] |
|
|
| [reply] |
|
|
|
|
| [reply] |
|
|
| [reply] |
|
|
| [reply] |
Re: keys %::
by deibyz (Hermit) on Apr 29, 2005 at 11:03 UTC
|
If it helps, Cygwin and Solaris output:
bash-2.03$ perl -le 'print for sort keys %::'
CYGWIN_NT-5.1 Solaris
============== =======
" "
$ $
+ +
- -
/ /
0 0
<none>:: <none>::
@ @
ARGV ARGV
CORE:: CORE::
Cwd:: DB::
DB:: DynaLoader::
DynaLoader:: ENV
ENV INC
INC IO::
IO:: Internals::
Internals:: PerlIO::
PerlIO:: Regexp::
Regexp:: STDERR
STDERR STDIN
STDIN STDOUT
STDOUT UNIVERSAL::
UNIVERSAL:: _
Win32:: _<-e
Win32CORE:: _<perlio.c
_ _<perlmain.c
_<Win32CORE.c _<universal.c
_<cygwin.c _<xsutils.c
_<perlio.c attributes::
_<perlmain.c main::
_<universal.c stderr
_<xsutils.c stdin
attributes:: stdout
main:: utf8::
stderr
stdin
stdout
utf8::
| [reply] [d/l] |
Re: keys %::
by tphyahoo (Vicar) on Apr 29, 2005 at 10:45 UTC
|
Neato. On my system (WinXP, ActiveState) I get
/
stderr
_<.\win32.c
_<perllib.c
utf8::
"
CORE::
DynaLoader::
stdout
attributes::
stdin
ARGV
INC
ENV
Regexp::
_<..\perlio.c
UNIVERSAL::
$
main::
-
Win32::
PerlIO::
_<..\universal.c
0
@
_<..\xsutils.c
STDOUT
IO::
_
+
STDERR
Internals::
STDIN
DB::
<none>::
Wish I could draw some brilliant conclusion from that... well, I do notice that, with regards to the .c files that get mentioned, with ActiveState you get perllib.c and win32.c instead of perlmain.c. | [reply] [d/l] |
Re: keys %::
by ysth (Canon) on Apr 29, 2005 at 17:01 UTC
|
I believe, but am not certain, that the only purpose of the empty Regexp::DESTROY is saving Perl the time and trouble of looking for UNIVERSAL::DESTROY, Regexp::AUTOLOAD, and UNIVERSAL::AUTOLOAD whenever a qr// is freed. | [reply] |
Re: keys %::
by johnnywang (Priest) on Apr 29, 2005 at 20:28 UTC
|
I changed it to also print out the values, and am delighted to find:
# on cygwin
perl -e 'print "$_ => $::{$_}\n" for keys %::'
__OUTPUT__
/ => *main::/
stderr => *main::stderr
_<.\win32.c => *main::_<.\win32.c
_<perllib.c => *main::_<perllib.c
utf8:: => *main::utf8::
" => *main::"
CORE:: => *main::CORE::
DynaLoader:: => *main::DynaLoader::
stdout => *main::stdout
attributes:: => *main::attributes::
↕ => *main::↕
stdin => *main::stdin
ARGV => *main::ARGV
INC => *main::INC
ENV => *main::ENV
Regexp:: => *main::Regexp::
_<..\perlio.c => *main::_<..\perlio.c
UNIVERSAL:: => *main::UNIVERSAL::
$ => *main::$
main:: => *main::main::
- => *main::-
Win32:: => *main::Win32::
PerlIO:: => *main::PerlIO::
_<..\universal.c => *main::_<..\universal.c
0 => *main::0
=> *main::
@ => *main::@
_<..\xsutils.c => *main::_<..\xsutils.c
STDOUT => *main::STDOUT
IO:: => *main::IO::
↑ => *main::↑
_ => *main::_
+ => *main::+
STDERR => *main::STDERR
Internals:: => *main::Internals::
STDIN => *main::STDIN
DB:: => *main::DB::
<none>:: => *main::<none>::
This "confirms" what I read somewhere that the symbol table contains the typeglob of the key, which apparently works for any package. Is there anyway to find out what the typeglobs really are? (i.e, its scalar value, array value, etc.) | [reply] [d/l] |
|
|
See broquaint's excellent node Of Symbol Tables and Globs.
fixed link
Thank you blazar, johnnywang and broquaint for an excellent education on the Perl symbol space.
s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s
|-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,,
$|=1,select$,,$,,$,,1e-1;print;redo}
| [reply] |
|
|
Yes... to see if something is a scalar you can do *something{SCALAR}. if it is a scalar then it will exists and it will be defined... (read `perldoc perlmod` if you need more information)
Or you could use the Devel::Symdump package...
| [reply] |
|
|
| [reply] |
|
|
|
|
Is there anyway to find out what the typeglobs really are? (i.e, its scalar value, array value, etc.)
Each slot in the GLOB, if defined, contains a reference to the actual value. The following works for looking up scalars, arrays, and hashes:
for my $g(sort keys %::) {
print "$g:\n";
if(defined( *{$g}{SCALAR} ) ) {
print " SCALAR: ", ${ *{$g}{SCALAR} }, "\n";
}
if(defined( *{$g}{ARRAY} ) ) {
print " ARRAY: ", join ", ", @{ *{$g}{ARRAY} }, "\n";
}
if(defined( *{$g}{HASH} ) ) {
print " HASH: ";
while(my ($k, $v) = each %{ *{$g}{HASH} } ) {
print "$k => $v, "
}
}
print "\n"
}
| [reply] [d/l] |
|
|
I have improved this script a bit, it can recurse into symbol tables now.
I learned something new today. Internals::SvREADONLY can reset the readonly flag :)
my $table=shift||'';
$table.="::";
dumptable($table);
sub dumptable{
my $table=shift;
my $indent=shift||'';
while (my ($key,$value)=each %$table ){
print qq!$indent"$key":\n!;
if(defined(*{$value}{SCALAR}) and defined(${ *{$value}{SCALAR}})){
print "$indent\tSCALAR: ",${*{$value}{SCALAR}}, "\n";
}
if(defined( *{$value}{ARRAY} ) ) {
print "$indent\tARRAY: ", join ", ",@{*{$value}{ARRAY}}, "\n";
}
if(defined( *{$value}{HASH} ) ) {
if ($key =~ /::$/){
print "$indent\tSYMTAB:\n";
dumptable($value,"\t".$indent)
if (*{$value}{NAME} ne "main::");
}else{
print "\tHASH:\n";
while(my ($k, $v) = each %{ *{$value}{HASH} } ) {
print "$indent\t\t$k => $v,\n"
}
}
}
if(defined( *{$value}{CODE} ) ) {
print "$indent\tCODE: ",*{$value}{CODE},"\n";
};
if(defined( *{$value}{IO} ) ) {
print "$indent\tIO: ",*{$value}{IO},"\n";
};
print "\n"
}
}
| [reply] [d/l] |