Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: exists *{$glob} ? (+)

by broquaint (Abbot)
on Sep 09, 2004 at 08:20 UTC ( #389586=note: print w/ replies, xml ) Need Help??


in reply to Re: exists *{$glob} ? (+)
in thread exists *{$glob} ? (+)

Further that to that you should also check for glob-ness since non-globs can live in symbol tables e.g

use strict; sub exists_glob { my $tbl = \%main::; $tbl = $tbl->{"$_\::"} for split '::', scalar caller; return exists $tbl->{$_[0]} && 'GLOB' eq ref \$tbl->{$_}; } $main::{foo} = "I'm a string"; *bar = \"I'm in a glob"; printf "%s is%s a glob\n", $_, (exists_glob($_) ? '' : "n't") for qw/ foo bar /; __output__ foo isn't a glob bar is a glob
HTH

_________
broquaint


Comment on Re^2: exists *{$glob} ? (+)
Download Code
Re^3: exists *{$glob} ? (+)
by ysth (Canon) on Sep 09, 2004 at 15:43 UTC
    Replacing the $main::{foo} line with sub foo (I am a string); gives a more realistic example.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://389586]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2014-09-22 21:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (203 votes), past polls