Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

A Little Good News

by dsb (Chaplain)
on Feb 21, 2001 at 21:41 UTC ( [id://59983]=poem: print w/replies, xml ) Need Help??

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 -

Replies are listed 'Best First'.
Re: A Little Good News
by danger (Priest) on Feb 21, 2001 at 21:55 UTC

    Congratulations kel! ... but a word of warning -- you are directly accessing object attributes ... providing accessor methods would be a safer way to go (now I realize, GirlFriend and Wife objects rarely (if ever) have a published interface, and it is all too easy to push the wrong buttons ... but just reaching in and grabbing what you want is simply asking for trouble :-)

Re: A Little Good News
by marius (Hermit) on Feb 21, 2001 at 21:47 UTC
    Congratulations are in order, then, Kel! (oh, and wise move on using strict with the girlfriend around! heh. makes you wonder if a -w would warn you about the impending lifelong commitments!)

    -marius
Re: A Little Good News
by arhuman (Vicar) on Feb 21, 2001 at 21:50 UTC

    Congratulations,
    for the poem and for your demand.
    (In fact I congratulate you mostly beccause she said yes... ;-)

      Thanks all for the congrats!!

      - kel -

Re: A Little Good News
by TStanley (Canon) on Feb 21, 2001 at 23:10 UTC
    Congrats kel! May you both find joy and happiness.

    TStanley
    In the end, there can be only one!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: poem [id://59983]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-26 02:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found