Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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 drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2015-11-29 20:38 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (753 votes), past polls