Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Tutorial: Introduction to Object-Oriented Programming

by jreades (Friar)
on Dec 10, 2002 at 13:07 UTC ( #218778=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use strict;
    
    ...
      my $hash_ref = shift;
      return $hash_ref->{approved};
    }
    
  2. or download this
    package Quote;
    
    ...
    }
    
    1;
    
  3. or download this
    use strict;
    use Quote;
    ...
    print STDOUT (Quote::is_approved() ? "Is approved" : "Is not approved"
    +), "\n";
    
    exit 0;
    
  4. or download this
    Foo
    Bar
    Is approved
    
  5. or download this
    package Quote;
    
    ...
    }
    
    1;
    
  6. or download this
    use strict;
    use Quote;
    ...
    print STDOUT ($quote->is_approved() ? "Is approved" : "Is not approved
    +"), "\n";
    
    exit 0;
    
  7. or download this
    Baz
    Foo
    Is not approved
    
  8. or download this
    sub new {
            my $class = shift;
    ...
            print STDOUT "Object ", $self, " is of class ", ref($self), "\
    +n";
            return $self;
    }
    
  9. or download this
    HASH
    Object Quote=HASH(0x804b514) is of class Quote
    Baz
    Foo
    Is not approved
    
  10. or download this
    sub set_phrase {
            my $self = shift;
    ...
            my $phrase = shift;
            $self->{phrase} = $phrase;
    }
    
  11. or download this
    Object Quote=HASH(0x804b514) is of class Quote
    
  12. or download this
    use strict;
    use Quote;
    ...
    print STDOUT $quote2->get_author(), " wrote ", $quote2->get_phrase(), 
    +"\n";
    
    exit 0;
    
  13. or download this
    Some other author wrote Baz
    Foo wrote Some other phrase
    
  14. or download this
    sub set_phrase {
            my $self = shift;
    ...
            my $self = shift;
            return $self->{invalid_message};
    }
    
  15. or download this
    sub set_phrase {
            my $self = shift;
    ...
            }
            $self->{author} = $author;
    }
    
  16. or download this
    package Saver;
    
    ...
    
    1;
    
  17. or download this
    use strict;
    use Quote;
    ...
    
    print STDOUT "Exiting\n";
    exit 0;
    
  18. or download this
    Exiting
    Closing file
    
  19. or download this
    sub serialize {
      my $self = shift;
    ...
      $text .= $quote->get_phrase();
      return $text;
    }
    
  20. or download this
    sub save {
            my $self = shift;
    ...
            }
            print {$self->{fh}} $self->serialize($quote) . "\n";
    }
    
  21. or download this
    $saver->save($quote2);
    $saver->save($quote1);
    
  22. or download this
    package Saver::Database;
    
    ...
            &_close();
            return;
    }
    
  23. or download this
    my $saver  = Saver::File->new($file);
    
  24. or download this
    my $saver  = Saver::Database->new($db, $user, $pass);
    
  25. or download this
    sub phrase {
      my $self = shift;
      @_ ? $self->{phrase} = shift : $self->{phrase};
    }
    
  26. or download this
    $quote->Set(phrase=>$phrase,author=>$author);
    
  27. or download this
    eval {
      $object->method($foo)
    ...
    if (@$) {
      ... handle error ...
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://218778]
Approved by rob_au
Front-paged by Tanalis
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2015-07-07 07:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls