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

Need to know on the differnece between the usgae of $st_mode and $'st_mode what does the single quote refer to

by Anonymous Monk
on Mar 25, 2010 at 05:40 UTC ( [id://830730]=perlquestion: print w/replies, xml ) Need Help??

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

I have come accross the code where in the global variable $st_mode is been accessed as $'st_mode what does the single quote in the variable $'st_mode refer to? Similarly there is a function call &'Stat so i am curious enough to know the real usgae of the quote

Replies are listed 'Best First'.
Re: Need to know on the differnece between the usgae of $st_mode and $'st_mode what does the single quote refer to
by ikegami (Patriarch) on Mar 25, 2010 at 05:45 UTC
    $'var is an obsolete notation for $::var, which is also known as $main::var

        For CPAN historians, this trick was also used by what I believe is the first CPAN joke module (D'oh), released several years before the Acme namespace was invented by TheDamian in 2001:

        I've also seen it employed in Perl Poetry, obfu and even golf (to improve the tie breaker by replacing sub SomeSub{...} with sub'SomeSub{...}).

Re: Need to know on the differnece between the usgae of $st_mode and $'st_mode what does the single quote refer to
by Anonymous Monk on Mar 26, 2010 at 12:04 UTC
    So is this the same case with &' and @' as well to access global function and global array respectively?
      No. ' is the name of the variable, and because you don't declare it, it is global, and because the current package is main, they are &main::' and @main::' respectively
      $ perl -le"print \@', \@{qq!main::'!}" ARRAY(0x979ff4)ARRAY(0x979ff4) $ perl -le"print &'" Undefined subroutine &main::' called at -e line 1.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://830730]
Approved by ikegami
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-03-29 12:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found