$SIG{QUIT} = "quit_catcher";     # implies "main::quit_catcher"
$SIG{QUIT} = *quit_catcher;      # forces current package's sub
$SIG{QUIT} = \&quit_catcher;     # forces current package's sub
$SIG{QUIT} = sub { print "Caught SIGQUIT\n" }   # anonymous sub
*****
local *somesym = *main::variable;
local *somesym = $main::{"variable"};
*****
foreach $symname (sort keys %main::) {
    local *sym = $main::{$symname};
    print "\$$symname is defined\n" if defined $sym;
    print "\@$symname is defined\n" if defined @sym;
    print "\%$symname is defined\n" if defined %sym;
}
*****
*dick = *richard;
*****
*dick = \$richard;
*****
%some_hash = ();
*some_hash = fn( \%another_hash );
sub fn {
    local *hashsym = shift;
    # now use %hashsym normally, and you
    # will affect the caller's %another_hash
    my %nhash = (); # populate this hash at will
    return \%nhash;
}
*****
*PI = \3.14159265358979;
*****
*pkg::sym{SCALAR}      # same as \$pkg::sym
*pkg::sym{ARRAY}       # same as \@pkg::sym
*pkg::sym{HASH}        # same as \%pkg::sym
*pkg::sym{CODE}        # same as \&pkg::sym
*pkg::sym{GLOB}        # same as \*pkg::sym
*pkg::sym{FILEHANDLE}  # internal filehandle, no direct equivalent
*pkg::sym{NAME}        # "sym" (not a reference)
*pkg::sym{PACKAGE}     # "pkg" (not a reference)
*****
        die "green\n";
END   { print "blue\n" }
BEGIN { print "red\n" }
*****
system "rm -rf '$dir'"
*****
sub AUTOLOAD {
    my $program = $AUTOLOAD;
    $program =~ s/.*:://;  # trim package name
    system($program, @_);
} 
date();
who('am', i');
ls('-l');
*****
use subs qw(date who ls);
date;
who "am", "i";
ls "-l";
*****
package      Fred;
require      Exporter;
@ISA       = qw(Exporter);
@EXPORT    = qw(func1 func2);
@EXPORT_OK = qw($sally @listabob %harry func3);
*****
use Module;
*****
use Module LIST;
*****
BEGIN {
    require "Module.pm";
    Module->import();
}
*****
BEGIN {
    require "Module.pm";
    Module->import(LIST);
}
*****
use Module ();
*****
BEGIN { require "Module.pm"; }
*****
require Module;
*****
require Cwd;    # make Cwd:: accessible with qualification
$here = Cwd::getcwd();

use Cwd;        # import names from Cwd:: -- no qualification necessary
$here = getcwd();
*****
use POSIX;
*****
use RedefineTheWorld;
*****
use subs qw(chdir chroot chmod chown);
chdir $somewhere;
sub chdir { ... }
*****
use Module 'open';
*****
use Module;
*****
package Critter;
sub new { return bless {}; }
*****
sub new {
    my     $obref = {};         # ref to empty hash
    bless  $obref;              # make it an object in this class
    return $obref;              # return it
}
*****
$circle->draw();
*****
sub new {
    my $self = {}
    bless $self;
    $self->_initialize();
    return $self;
}
*****
sub new {
    my $class = shift;
    my $self = {};
    bless $self, $class;        # bless $self into the designated class
    $self->_initialize();       # in case there's more work to do
    return $self;
}
*****
$a = {};            # generate reference to hash
$b = $a;            # reference assignment (shallow)
bless $b, Mountain;
bless $a, Fourteener;
print "\$b is a ", ref($b), "\n";
*****
sub find {
    my ($class, $nickname) = @_;
    return $objtable{$nickname};
}
*****
sub display {
    my $self = shift;
    my @keys;
    if (@_ == 0) {                  # no further arguments
        @keys = sort keys(%$self);
    }  else {
        @keys = @_;                 # use the ones given
    }
    foreach $key (@keys) {
        print "\t$key => $self->{$key}\n";
    }
}
*****
$ob1  = StarKnight->new();
$luke = $ob1->new();
*****
package StarKnight;
sub new {
    my $self  = shift;
    my $type  = ref($self) || $self;
    return bless {}, $type;
} 
*****
METHOD CLASS_OR_INSTANCE LIST
*****
$fred = find Critter "Fred";
display $fred 'Height', 'Weight';
*****
display { find Critter "Fred" } 'Height', 'Weight';
*****
CLASS_OR_INSTANCE->METHOD(LIST)
*****
$fred = Critter->find("Fred");
$fred->display('Height', 'Weight');
*****
Critter->find("Fred")->display('Height', 'Weight');
*****
new Critter ('Barney', 1.5, 70);
*****
new Critter ('Bam' x 2), 1.4, 45;
*****
Critter->new('Bam' x 2), 1.4, 45;
*****
$fred = MyCritter::find("Critter", "Fred");
MyCritter::display($fred, 'Height', 'Weight');
*****
$fred = Critter->MyCritter::find("Fred");
$fred->MyCritter::display('Height', 'Weight');
*****
$self->SUPER::display('Height', 'Weight');
*****
$method = $fast ? "findfirst" : "findbest";
$fred->$method(@args);
*****
A: method $obref->{fieldname}
B: (method $obref)->{fieldname}

C: $obref->{fieldname}->method()
D: method {$obref->{fieldname}}
*****
$object = tie VARIABLE, CLASSNAME, LIST

untie VARIABLE

$object = tied VARIABLE
*****
package Some_Class;
sub some_method {
    my $self = shift;
    unless (ref($self) eq "Some_Class") {          # WRONG
        croak "I'm not a Some_Class anymore!";
    }
    unless (ref $self) {                           # better
        croak "bad method call";
    }
}
*****
