class Foo extends Bar {
use LWP::Simple qw(get) ; ## import the method get() to this package.
vars ($GLOBAL_VAR) ; ## same as: use vars qw($GLOBAL_VAR);
my ($local_var) ;
## constructor/initializer:
sub Foo {
$this->{attr} = $_[0] ;
}
## method with input variables declared:
sub get_pages ($base , \@pages , \%options) {
my @htmls ;
if ( $options{proxy} ) { ... }
foreach my $pages_i ( @pages ) {
my $url = "$base/$pages_i" ;
my $html = get($url) ;
push(@htmls , $html) ;
$this->cache($url , $html) ;
}
return @htmls ;
}
## method like a normal Perl sub:
sub cache {
my ( $url , $html ) = @_ ;
$this->{CACHE}{$url} = $html ;
}
}
####
package main ;
my $foo = new Foo(123) ;
$foo->get_pages('http://www.perlmonks.com/', ['/index.pl','/foo'] , {proxy => 'localhost:8080'}) ;
####
sub test {
my $this = shift ;
my ( $arg1 , @list ) = @_ ;
$this->other(...);
}
####
sub test ($arg1 , @list) {
$this->other(...);
}
####
sub testref ($arg1 , \@list , \%hash) {
$this->other(...);
}
## use:
$object->testref("foo" , [1,2,3] , {k1 => 1})
####
sub testref {
my $arg1 = $_[0] ;
my @list = @{$_[1]} ;
my %hash = %{$_[2]} ;
$this->other(...);
}
####
class Foo extends Bar, Baz {...}