Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Blessables -- What Can You Make Into Objects?

by chromatic (Archbishop)
on Apr 20, 2000 at 23:52 UTC ( #8259=perltutorial: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    package Soldier;
    
    use constant NAME => 0;
    ...
    }
    
    # similar methods for RANK and SERIAL
    
  2. or download this
    package Password;
    
    use Digest::MD5 qw(md5_base64);        # based on an idea by jbontje
    ...
        my $candidate = shift;
        return ($self eq md5_base64($candidate));
    }
    
  3. or download this
    package WordMatch;
    
    sub new {
    ...
    
    print $wm->match("[hi] how are you?"), "\n";
    print $wm->match("hi how are you?"), "\n";
    
  4. or download this
    package ReadFile;
    
    ...
        my $line = <$self>;
        return  $line;
    }
    
  5. or download this
    my $file = ReadFile->new("obself.pl");
    print $file->read_record("package");
    print $file->read_record();
    
  6. or download this
    sub DESTROY {
        my $self = shift;
        close $self;
        print "Closed!\n";        # just to prove that it's working
    }
    
  7. or download this
    package SubBrowser;
    
    sub new {
    ...
        my $self = shift;
        return &$self;
    }
    
  8. or download this
    package Wrapper;
    
    use vars '$AUTOLOAD';
    ...
    # our new version
    my $wm2 = Wrapper->new(WordMatch->new("Hello"));
    print $wm2->match("[Hello] little girl"), "\n";
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://8259]
help
Chatterbox?
[james28909]: and like i say, is just an example, not working code, but hopefully you understand what i mean. :)
[james28909]: and like i say, it would be alot of work to get around renaming 3 subs haha
[Lady_Aleena]: Well, you would have to add the file munging and a lot more.
[james28909]: yeah but it would rename those subs xD
[Lady_Aleena]: I'd say, go back to my scratchpad, and really look at what the 3 subs are doing, then play. Meanwhile, I am going afk for about an hour +/- a few minutes.

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2017-05-24 05:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?