Created
June 24, 2016 20:48
-
-
Save opendevnet/1bce50b1682b53333171f6dd0cb14dd7 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
package Surfz ; | |
use Function::Parameters ; | |
use base 'Sub::Attributes'; | |
fun new :ClassMethod { | |
my $class = shift; | |
my $self = {}; | |
bless $self, $class; | |
return $self; | |
} | |
# croak if not called as a class method | |
method rocks :ClassMethod { | |
print "the surf rox\n"; | |
} | |
method flow :Method { | |
print "Ok better now some flow\n"; | |
} | |
fun wheee () { | |
print "This sub is fun!!\n"; | |
} | |
sub whee { | |
print "Some fun as a sub!!\n"; | |
} | |
package main; | |
Surfz->rocks() ; | |
# Surfz::rocks(); fatal unless s/croak/carp/ in Sub/Atrributes.pm | |
Surfz::whee() ; | |
Surfz::wheee() ; | |
Surfz->wheee() ; | |
print "\ninstances coming up\n\n"; | |
my $surf = Surfz->new() ; | |
# $surf->rocks(); | |
$surf->flow(); # Surfz::flow() and Surfz->flow() will fail | |
$surf->whee() ; | |
$surf->wheee() ; | |
# | |
use DDP; | |
$subs = $surf->sub_attributes(); | |
p $subs; |
Author
opendevnet
commented
Jun 24, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment