targetsmart has asked for the wisdom of the Perl Monks concerning the following question:
Now my question is what is the difference between *a and *a{GLOB}, if both are same then why do we have two pointing to same area?. Please clarifyprint "-"x80,"\n"; $a = 1; @a = (1..10); %a = (10..20); open(a,"/etc/passwd") or die "can't open /etc/passwd : $!"; sub a { "TEST" }; format a = @>>>>>>>> . &DumpGlob(*a); print "-"x80,"\n"; sub DumpGlob { my $symbol = shift; if(defined *{$symbol}{SCALAR}) { print "SCALAR defined >",${*{$symbol}{SCALAR}},"<\n"; } if(defined *{$symbol}{ARRAY}) { print "ARRAY defined >",@{*{$symbol}{ARRAY}},"<\n"; } if(defined *{$symbol}{HASH}) { print "HASH defined >",%{*{$symbol}{HASH}},"<\n"; } if(defined *{$symbol}{IO}) { print "IO defined >",*{$symbol}{IO},"<\n"; } if(defined *{$symbol}{CODE}) { print "CODE defined >",*{$symbol}{CODE},"<\n"; } if(defined *{$symbol}{FORMAT}) { print "FORMAT defined >",*{$symbol}{FORMAT},"<\n"; } if(defined *{$symbol}{GLOB}){ print "GLOB defined >",${*{$symbol}{GLOB}},"<\n"; } } the output is like this SCALAR defined >1< ARRAY defined >12345678910< HASH defined >1819161710111213201415< IO defined >IO::Handle=IO(0x8154a2c)< CODE defined >CODE(0x81735b0)< FORMAT defined >FORMAT(0x81735f8)< GLOB defined >*main::a<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: what is the difference between *a and *a{GLOB}?
by tilly (Archbishop) on Feb 01, 2009 at 01:28 UTC | |
|
Re: a doubt in typeglob
by Anonymous Monk on Jan 31, 2009 at 13:51 UTC | |
by BrowserUk (Patriarch) on Jan 31, 2009 at 15:17 UTC | |
by stonecolddevin (Parson) on Jan 31, 2009 at 17:50 UTC | |
by Anonymous Monk on Jan 31, 2009 at 15:38 UTC | |
by BrowserUk (Patriarch) on Jan 31, 2009 at 15:55 UTC | |
by Anonymous Monk on Jan 31, 2009 at 16:16 UTC | |
|