Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have been reading through some intermediate level code and I have come accross variables or references that have an asterix in front of them. I am trying to determine the significance of this asterix. Is it a pointer...???

Here are just a few examples of how I have seen them used:

local(*dbline) = $main::{'_<' . $fname}; local(*F); *GUI:: = \%Win32::GUI::;
I have tried to do searches on "*" but as you can imagine it is a hard thing to search on.

Thanks in advance to anyone that can clue me in on this.

update (broquaint): added <code> tags

  • Comment on What does the "*" means when placed infront of a variable or reference?
  • Download Code

Replies are listed 'Best First'.
Re: What does the "*" means when placed infront of a variable or reference?
by edan (Curate) on Feb 18, 2004 at 14:55 UTC
Re: What does the "*" means when placed infront of a variable or reference?
by broquaint (Abbot) on Feb 18, 2004 at 15:14 UTC
    Used in that context, the * is the sigil for globs (as $ is the sigil for scalars and @ the sigil for arrays and % the sigil for hashes). A glob is a 'storage unit' for package variables, and globs themselves live within symbol tables (although they can also live seperate of them see. Symbol's gensym()). For more info on globs see Of Symbol Tables and Globs.
    HTH

    _________
    broquaint

Re: What does the "*" means when placed infront of a variable or reference?
by antirice (Priest) on Feb 18, 2004 at 14:54 UTC

    They affect symbol table entries. For a better understanding of how they work, take a look at perldoc perlmod under the Symbol Tables section.

    antirice    
    The first rule of Perl club is - use Perl
    The
    ith rule of Perl club is - follow rule i - 1 for i > 1

Re: What does the "*" means when placed infront of a variable or reference?
by ysth (Canon) on Feb 18, 2004 at 18:28 UTC
    Translation of those lines:
    # %main:: is the main symbol table (the :: are part of # the variable name in this case) # lookup the entry for "_<$fname" (note that symbol # tables can contain not-normally-valid identifiers # that are accessible only via the symbol table hash or # via symbolic references) # in this scope only, alias *dbline to *{"_<$fname"}. # this will alias $dbline, @dbline, %dbline, etc. # though I'm guessing that only the filehandle is # actually wanted. local(*dbline) = $main::{'_<' . $fname}; # for this scope, hide $F, @F, *F, etc. and use fresh ones # typically used to say things like open F, ... without # worrying that some other code is using the F filehandle. local(*F); # Make the GUI:: symbol table (aka package) an alias to # Win32::GUI:: *GUI:: = \%Win32::GUI::;
Re: What does the "*" means when placed infront of a variable or reference?
by Anonymous Monk on Feb 18, 2004 at 16:23 UTC
    Thank you all for the quick response, now that I have a starting point I can dig in....