Address.pl
#!/usr/bin/perl
pacakge Address;
sub new {
my $package = shift;
my $self = {@_};
return bless $self, $package;
}
sub country {
my $self = shift;
return @_ ? ($self->{country} = shift) : $self->{country};
}
sub as_string {
my $self = shift;
my $string;
foreach (qw(name street city zone country)) {
$string .= "$self->{$_}\n" if defined $self->{$_};
}
return $string;
}
$test = Address-> new (
name => "Sam Gamgee",
street => "Bagshot Row",
city => "Hobbiton",
country => "The Shire",
);
test.pl
use Address;
$test = Address-> new (
name => "Sam Gamgee",
street => "Bagshot Row",
city => "Hobbiton",
country => "The Shire",
);
print $test->as_string;
2 つの perl ファイルが同じフォルダーにある test.pl の use Address 行で Address が見つかりません。
test.pl が Address.pl を表示するにはどうすればよいですか?