- or download this
## create an anonymous block to limit the scope of the package
{
...
$VAR1 = {
'var' => *globtut::var
};
- or download this
$globtut::var = "a string";
@globtut::var = qw( a list of strings );
...
$VAR1 = {
'var' => *globtut::var
};
- or download this
use Data::Dumper;
{
...
package globtut::child;
## ^^
}
- or download this
use Data::Dumper;
{
...
exists: exists
delete: deleted
defined: no foo
- or download this
{
package globtut;
...
__output__
*globtut::variable
- or download this
{
package globtut;
...
__output__
$variable: a string
- or download this
$scalar = "a simple string";
print *scalar{SCALAR}, "\n";
...
__output__
SCALAR(0x8107e78)
- or download this
$scalar = "a simple string";
print ${ *scalar{SCALAR} }, "\n";
...
__output__
a simple string
- or download this
$scalar = "a simple string";
print $::scalar, "\n";
...
__output__
a simple string
- or download this
$scalar = "a simple string";
print ${ *{$main::{scalar}}{SCALAR} }, "\n";
...
__output__
a simple string
- or download this
${ *scalar{FOO} } = "the FOO data type";
__output__
Can't use an undefined value as a SCALAR reference at - line 1.
- or download this
## this is fine as we're dereferencing the stored reference
${ *foo{SCALAR} } = "a string";
...
__output__
Can't modify glob elem in scalar assignment at - line 5, near ""a stri
+ng";"
- or download this
*foo = \"a scalar";
print $foo, "\n";
...
a scalar
alistofstrings
a subroutine
- or download this
use Data::Dumper;
## use a fresh uncluttered package for minimal Dumper output
...
'string' => *globtut::string,
'foo' => *globtut::string
};
- or download this
## put this code in Foo.pm
...
}
q</package Foo>;
- or download this
use Data::Dumper;
## we'll stay out of the 'polluted' %main:: symbol table
...
'BEGIN' => *globtut::BEGIN,
'fooify' => *globtut::fooify
};