mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
use strict and warnings in example modules
This commit is contained in:
parent
35b3c490ce
commit
88af462c69
@ -202,6 +202,8 @@ logger("We have a logger subroutine!");
|
|||||||
# that Perl can find it.
|
# that Perl can find it.
|
||||||
|
|
||||||
package MyModule;
|
package MyModule;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
sub trim {
|
sub trim {
|
||||||
my $string = shift;
|
my $string = shift;
|
||||||
@ -237,6 +239,8 @@ trim($string);
|
|||||||
# or Moo (see below).
|
# or Moo (see below).
|
||||||
|
|
||||||
package MyCounter;
|
package MyCounter;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
@ -268,7 +272,7 @@ print $counter->count, "\n"; # 1
|
|||||||
# class can be used equivalently to the one above.
|
# class can be used equivalently to the one above.
|
||||||
|
|
||||||
package MyCounter;
|
package MyCounter;
|
||||||
use Moo;
|
use Moo; # imports strict and warnings
|
||||||
|
|
||||||
has 'count' => (is => 'rwp', default => 0, init_arg => undef);
|
has 'count' => (is => 'rwp', default => 0, init_arg => undef);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user