-
Notifications
You must be signed in to change notification settings - Fork 1
Perl developer guide
Learn Perl in about 2 hours 30 minutes - http://qntm.org/files/perl/perl.html
https://metacpan.org/pod/distribution/perl/pod/perlootut.pod RUS
https://metacpan.org/pod/distribution/perl/pod/perlobj.pod
https://perlmaven.com/oop-with-moo
https://metacpan.org/pod/distribution/Moose/lib/Moose/Cookbook.pod
https://metacpan.org/pod/distribution/Moose/lib/Moose/Manual/Attributes.pod
https://metacpan.org/pod/distribution/perl/pod/perlstyle.pod
https://metacpan.org/pod/distribution/Perl-Tidy/bin/perltidy
https://habrahabr.ru/post/233991/
https://pause.perl.org/pause/query?ACTION=pause_namingmodules
The @ISA
array contains a list of that class's parent classes, if any
https://www.youtube.com/user/gabor529/videos
http://modernperlbooks.com/books/modern_perl_2016/07-object-oriented-perl.html
I recommend to use PyCharm Community Edition with Perl Plugin
It allow quicky:
- jump to variable or function declaration (Ctr+B shortcut)
- find a class by name (Ctrl+N)
- auto-tidy and auto-indent source code before commit
dockerctl.sh prove
E.g. you can STDOUT all input parameters of particular method:
sub list {
my ($calendar, $span) = @_;
warn "".(caller(0))[3]."() : ".Dumper \@_; # return a list, $calendar - first element, $span - second
It's good idea to always pass arguments to new class or function as named hashes if arguments > 2. Named params are always better
So don't do like this (InstructorFSMController.pm)
sub new {
my ($class, $user,
$chat_id, $api,
$instructors, $resources, $recordtimeparser) = @_;
my $self = $class->SUPER::new($chat_id, $api); # init instance of parent class (BaseFSMController)
$self->{instructor} = $instructors->name($user->{id});
$self->{resources} = $resources;
$self->{recordtimeparser} = $recordtimeparser;
$self->{log} = Log->new("instructorfsmcontroller");
$self;
}
So call of this method will be (FSMFactory.pm)
InstructorFSMController->new(
$user,
$chat_id,
$self->{api},
$self->{instructors},
$self->{resources},
$self->{recordtimeparser}));
}
When following style guide
sub new {
my ($class, $params) = @_; # $params - hash with named parameters
my $self = $class->SUPER::new($params->{chat_id}, $params->{api}); # init instance of parent class (BaseFSMController)
$self->{instructor} = ($params->{instructors})->name($params->{user}{id});
$self;
}
has recources;
has recordtimeparser;
has log => Log->new("instructorfsmcontroller");
# ...
InstructorFSMController->new(
user => $user,
chat_id => $chat_id,
api => $self->{api},
instructors => $self->{instructors},
resources => $self->{resources},
recordtimeparser => $self->{recordtimeparser}
);