Created
March 13, 2012 04:56
-
-
Save Cside/2026856 to your computer and use it in GitHub Desktop.
Inheritance test on Perl
This file contains hidden or 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/env perl | |
use strict; | |
use warnings; | |
use lib './'; | |
{ | |
package Child; | |
use strict; | |
use warnings; | |
use parent qw(Parent); # => error | |
# use base qw(Parent); # => works | |
1; | |
} | |
my $child = Child->new; | |
# => Can't locate object method "new" via package "Child" at ... |
This file contains hidden or 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 Parent; | |
use strict; | |
use warnings; | |
sub new { bless {}, $_[0] } | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment