Created
February 1, 2014 19:29
-
-
Save rjbs/8757352 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN { unshift @INC, 'lib'; } | |
use 5.19.0; | |
use feature 'signatures'; | |
use warnings; | |
no warnings 'experimental::signatures'; | |
sub add ($x, $y = 0) { return $x + $y; } | |
use JSON::PP; | |
sub obj (%data) { say JSON::PP->new->encode(\%data) } | |
say add(1,2) // -1; | |
say add(6) // -1; | |
say obj(%INC); | |
use Data::Dumper; | |
sub foo ($, $z = undef, @) { say Dumper(\@_) } | |
sub bar ($=, $z = undef, @) { say Dumper(\@_) } | |
foo(1,2); | |
bar(1,2); | |
bar(); | |
sub add2 ($x, $y = return $x) { return $x + $y; } | |
say add2(123); | |
say add2(123,321); | |
sub xyz( $p1, $p2 = 3, $p3 = 4 ) { say "p1 = $p1, p2 = $p2, p3 = $p3" } | |
say xyz(10, ,70); | |
package X { | |
sub new ($class, $arg) { bless $arg, $class } | |
sub dump ($self) { say Data::Dumper::Dumper($self) } | |
} | |
my $x = X->new({}); | |
$x->dump; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment