Created
March 25, 2013 09:38
-
-
Save satomixx/5236000 to your computer and use it in GitHub Desktop.
スゲい簡単なPerl入門 -2ndDay ref: http://qiita.com/items/43320da7c38813b805ce
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
my $pkg = shift; |
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 main; | |
use Stonge; | |
my $obj = Stone->new('brick','100'); |
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
$obj = Stone::new('Stone','brick','100'); |
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
# 1st argument of Stone module is inserted here. | |
my $pkg = shift; | |
# 2nd and 3rd arguments are inserted here. | |
my $hash = { | |
# 2nd argument | |
name => shift; | |
# 3rd argument | |
weight => shift; | |
}; | |
bless $hash, $pkg; |
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
#!/usr/bin/perl -w | |
package Stone; | |
sub new{ | |
my $pkg = shift; | |
my $hash = { | |
name => shift, | |
weight => shift | |
}; | |
bless $hash, $pkg; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment