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 -
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.