#!/usr/local/bin/perl -w package Mary; $lamb = new Sheep (size => 'little'); $lamb->fleece("#FFFFFF"); sub go { my $self = shift; $location = shift; $lamb->go($location); } Mary->go('school'); package Sheep; sub new { my $class = shift; bless { @_ }, $class; } sub fleece { my $sheep = shift; $sheep->{fleece} = shift; } sub go { my $sheep = shift; $sheep->{location} = shift; if ($sheep->{location} =~ /school/i) { warn "Sheep are not allowed at school.\n"; Children->see($sheep, $sheep->{location}); } } package Children; sub see { my $children = shift; my($object, $location) = @_; if ($object->isa('Sheep') and $location =~ /school/i) { $children->laugh(); $children->play(); } } sub laugh { print "Hahaha!\n"; } sub play { print "Whee!\n"; } # # Mary had a little lamb # Its fleece was white as snow # And everywhere that Mary went # The lamb was sure to go # # It followed her to school one day # Which was against the rules # It made the children laugh and play # To see a lamb at school #

In reply to mary.pl by chipmunk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.