Take heed...this is not poetry until is actually run, or until you can figure out what will be output and how. Anyway, here's the code...
#!/usr/bin/perl -w
use Ring;
use GirlFriend;
use strict;
my $gf = GirlFriend->new();
my $ring = Ring->new();
print "I love my ", ref( $gf ), " ", $gf->{name}, "...\n";
print "So I gave her this ", $ring->{ring}, " ", ref( $ring ), "\n";
print "She's the best...\n";
print " She said yes...\n";
print " She makes me want to sing\n\n";
print "\t\t\t-Kel :)\n";
That's for the main script. Here are the two packages.
One.
#!/usr/bin/perl -w
package Ring;
use strict;
sub new {
my $class = shift;
my $self = { };
if ( !( $class ) ) {
die "Usage: 'Ring->new()'\n";
}
bless $self, $class;
$self->{ring} = "Pretty";
return $self;
}
1;
Two
#!/usr/bin/perl -w
package GirlFriend;
use strict;
sub new {
my $class = shift;
my $self = { };
if ( !( $class ) ) {
die "Usage: 'GirlFriend->new()'\n";
}
bless $self, $class;
$self->{name} = "Beth";
return $self;
}
1;
Nothing too complex. Just something I couldn't hold in any longer. :)
- kel -