Feel guilty to ask a seemingly babyish question but, either due to bad luck, drowsiness or sheer sloth, I couldn't seem to be able to locate documentation concerning something like $p'a = $a, which I came across in a Perl script I read off the Web. So, I tried that syntax out on a script in attempt to figure things out myself:
#! /usr/local/bin/perl -w
use strict ;
# ----------------------------------------------------------
my $a = "this\n";
sub this {$p'a = $a; print $p::a;}
sub that {$p::a = "that\n"; print $p'a;}
sub more {$p::a = "more\n"; print $a;}
this(); # print "this"
that(); # print "that"
more(); # print "this"
print $p'a; # print "more"
print $p::a; # print "more"
print $a; # print "this"
# ----------------------------------------------------------
sub a'this {$p'u'a = "mooo\n"; print $p::u::a;}
a::this(); # print "mooo"
print $p'u'a; # print "mooo"
# ----------------------------------------------------------
sub a::that {$p't'u = "wwoo\n"; return sub{print $p't'u}}
$a'that = a'that();
$a'that->(); # print "wwoo"
$a'that = a'that();
$p::t::u = "booo\n";
$a'that->(); # print "booo"
Does that mean $p'a is a namespace thing? I don't quite comprehend what scope $p'a is. Is it the same thing as $package::var_or_func?
Thanks. This has been a resourceful community here.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.