Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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


Comment on Re^2: exists *{$glob} ? (+)
Download Code
Replies are listed 'Best First'.
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?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (12)
As of 2016-02-12 08:43 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (391 votes), past polls