Professional Web Applications Themes

packages object oriented - PERL Beginners

Does anyone have a good hold of how to do object oriented programming in perl? Maybe a few lines of code as examples? EDUB...

Sponsored Links
  1. #1

    Default packages object oriented

    Does anyone have a good hold of how to do object oriented programming in
    perl? Maybe a few lines of code as examples?
    EDUB



    Sponsored Links
    Eric Walker Guest

  2. #2

    Default RE: packages object oriented



    Have a look at Tom's Object Oriented Tutorial

    man perltoot or perldoc perltoot

    Jim

    -----Original Message-----
    From: Eric Walker [mailto:ewalkermicron.com]
    Sent: 12 September 2003 15:33
    To: perlgroup
    Subject: packages object oriented


    Does anyone have a good hold of how to do object oriented programming in
    perl? Maybe a few lines of code as examples?
    EDUB


    Jim Halkyard Guest

  3. #3

    Default Re: packages object oriented

    On Friday, September 12, 2003, at 09:32 AM, Eric Walker wrote:
    > Does anyone have a good hold of how to do object oriented programming
    > in
    > perl? Maybe a few lines of code as examples?
    I feel my grasp of the concept is strong, but perhaps myself, and
    others, could help more if we knew what you're trying.

    Are you familiar with Object Oriented Programming concepts in general?
    Have you used it other languages?

    Object Oriented Perl is an excellent book, if you're interested.

    James

    James Edward Gray II Guest

  4. #4

    Default Re: packages object oriented

    I have a small grasp of the concept, but what I am doing involves a
    better understanding than I have. I am doing a project that will allow
    a user to build a particular file called a do file. Its used in a route
    tool called iccraftsman. In this particular file it has several
    sections. Each section has a few things that are alike. It seems that
    when I am done this is going to be a pretty big program as we have lots
    of ideas about functionality. So I figured I would try to do it in OOP
    style for ease of future changes and maintainance. Hope this helps..

    EDUB
    On Fri, 2003-09-12 at 08:42, James Edward Gray II wrote:

    On Friday, September 12, 2003, at 09:32 AM, Eric Walker wrote:
    > Does anyone have a good hold of how to do object oriented programming
    > in
    > perl? Maybe a few lines of code as examples?
    I feel my grasp of the concept is strong, but perhaps myself, and
    others, could help more if we knew what you're trying.

    Are you familiar with Object Oriented Programming concepts in general?
    Have you used it other languages?

    Object Oriented Perl is an excellent book, if you're interested.

    James



    Eric Walker Guest

  5. #5

    Default Re: packages object oriented

    It does help. It tells me that a few lines of code aren't going to do
    anything for you here. :) I really suggest you look into some of the
    resources we've suggested. It just sounds like you knowledge level is
    going to need a boost. Sorry if that's not the answer you were looking
    for.

    James

    On Friday, September 12, 2003, at 09:59 AM, Eric Walker wrote:
    > I have a small grasp of the concept, but what I am doing involves a
    > better understanding than I have. I am doing a project that will allow
    > a user to build a particular file called a do file. Its used in a
    > route
    > tool called iccraftsman. In this particular file it has several
    > sections. Each section has a few things that are alike. It seems that
    > when I am done this is going to be a pretty big program as we have lots
    > of ideas about functionality. So I figured I would try to do it in OOP
    > style for ease of future changes and maintainance. Hope this helps..
    >
    > EDUB
    > On Fri, 2003-09-12 at 08:42, James Edward Gray II wrote:
    >
    > On Friday, September 12, 2003, at 09:32 AM, Eric Walker wrote:
    >
    >> Does anyone have a good hold of how to do object oriented programming
    >> in
    >> perl? Maybe a few lines of code as examples?
    >
    > I feel my grasp of the concept is strong, but perhaps myself, and
    > others, could help more if we knew what you're trying.
    >
    > Are you familiar with Object Oriented Programming concepts in
    > general?
    > Have you used it other languages?
    >
    > Object Oriented Perl is an excellent book, if you're interested.
    >
    > James
    >
    >
    James Edward Gray II Guest

  6. #6

    Default Re: packages object oriented

    On Fri, Sep 12, 2003 at 08:32:38AM -0600, Eric Walker wrote:
    > Does anyone have a good hold of how to do object oriented programming
    > in perl? Maybe a few lines of code as examples?
    There are some tutorials in the standard docs.

    $ perldoc perlobj
    $ perldoc perlboot
    $ perldoc perltoot

    You'll also need (as I believe the tutorials will tell you) to
    understand subroutines, packages and modules, and references.

    $ perldoc perlmod
    $ perldoc perlsub
    $ perldoc perlreftut
    $ perldoc perlref

    --
    Steve
    Steve Grazzini Guest

  7. #7

    Default Re: packages object oriented

    Thanks all for the good resources on OOP. I have been reading a few
    perl books and it seemed not to sink in. the link that I got on the web
    does it for me. The light has clicked. Now I just have to read the
    rest and apply it. Thanks again all for your help.

    EDUB
    On Fri, 2003-09-12 at 10:48, Steve Grazzini wrote:

    On Fri, Sep 12, 2003 at 08:32:38AM -0600, Eric Walker wrote:
    > Does anyone have a good hold of how to do object oriented programming
    > in perl? Maybe a few lines of code as examples?
    There are some tutorials in the standard docs.

    $ perldoc perlobj
    $ perldoc perlboot
    $ perldoc perltoot

    You'll also need (as I believe the tutorials will tell you) to
    understand subroutines, packages and modules, and references.

    $ perldoc perlmod
    $ perldoc perlsub
    $ perldoc perlreftut
    $ perldoc perlref

    --
    Steve


    Eric Walker Guest

  8. #8

    Default Re: packages object oriented

    >>>>> "Eric" == Eric Walker <ewalkermicron.com> writes:

    Eric> Does anyone have a good hold of how to do object oriented programming in
    Eric> perl? Maybe a few lines of code as examples?

    "perldoc perlboot".

    Or, if you like the feel of paper,
    "Learning Perl Objects References and Modules", where perlboot has
    been greatly expanded and exercised.

    --
    Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
    <merlynstonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
    Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
    See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
    Randal L. Schwartz Guest

  9. #9

    Default Re: packages object oriented

    Eric Walker wrote:
    > I have a small grasp of the concept,
    What concept? We don't know what you are responding to.
    > but what I am doing involves a
    > better understanding than I have. I am doing a project that will allow
    > a user to build a particular file called a do file. Its used in a route
    > tool called iccraftsman. In this particular file it has several
    > sections. Each section has a few things that are alike. It seems that
    > when I am done this is going to be a pretty big program as we have lots
    > of ideas about functionality. So I figured I would try to do it in OOP
    > style for ease of future changes and maintainance. Hope this helps..
    perldoc perlobj

    See where that leads you. It is the basic doentation of OO Perl. To make
    good use of it, you will also have to understand references. In brief:

    Greetings! E:\d_drive\perlStuff>sample_test.pl
    Title: Sample of Object Formation in Perl
    Purpose: To demonstrate creation of a very simple Perl class, and creation of
    ap
    propriate methods

    Here is the text of Sample.pm

    use strict;
    use warnings;

    package Sample;

    sub new {
    my $this = shift;
    my $class = ref($this) || $this;
    my $self = {};
    bless $self, $class;
    $self->initialize(_); # parameter my addition to sample
    return $self;
    }
    # from perldoc perlref [perlref.pod]
    # That is really standard. You can pretty much plug that in for any class,
    then
    start to differentiate
    # your class in the initialize function.

    sub initialize {
    my $self = shift; # references the oblect.
    my ($title, $purpose, $text) = _;

    $self->{'Title'} = $title;
    $self->{'Purpose'} = $purpose;
    push {$self->{'Text'}}, $_ foreach $text;
    return $self;
    }

    sub print {
    my $self = shift;

    print "Title: ";
    print "$self->{'Title'}" if $self->{'Title'};
    print "\nPurpose: ";
    print "$self->{'Purpose'}" if $self->{'Purpose'};
    print "\n\n";
    if ($self->{'Text'}) {
    chomp {$self->{'Text'}};
    print "$_\n" foreach {$self->{'Text'}};
    }
    }

    1;
    __END__

    Here is the executing code

    #!perl -w

    use strict;
    use warnings;

    use Sample;

    my $sample_text = [];

    push {$sample_text}, 'Here is the text of Sample.pm', '';
    open IN, 'Sample.pm' or die "Can't open module file $!";
    push {$sample_text}, $_ while <IN>;
    push {$sample_text}, '';
    push {$sample_text}, 'Here is the executing code', '';
    close IN;
    open IN, $0;
    push {$sample_text}, $_ while <IN>;
    close IN;

    my $sample = Sample->new('Sample of Object Formation in Perl',
    'To demonstrate creation of a very simple Perl class, ' .
    'and creation of appropriate methods',
    $sample_text);
    $sample->print();

    Greetings! E:\d_drive\perlStuff>

    Joseph

    R. Joseph Newton Guest

  10. #10

    Default Re: packages object oriented

    "R. Joseph Newton" wrote:
    >
    > sub initialize {
    > my $self = shift; # references the oblect.
    > my ($title, $purpose, $text) = _;
    >
    > $self->{'Title'} = $title;
    > $self->{'Purpose'} = $purpose;
    > push {$self->{'Text'}}, $_ foreach $text;
    > return $self;
    > }
    Sorry, there was some wasted processing there.
    # push {$self->{'Text'}}, $_ foreach $text;
    $self->{'Text} = $text;

    Duuuuh.

    Joseph

    R. Joseph Newton Guest

  11. #11

    Default Re: packages object oriented


    "R. Joseph Newton" <rjnewtonefn.org> wrote in message news:3F62B5AD.63FF355Eefn.org...
    > "R. Joseph Newton" wrote:
    >
    > >
    > > sub initialize {
    > > my $self = shift; # references the oblect.
    > > my ($title, $purpose, $text) = _;
    > >
    > > $self->{'Title'} = $title;
    > > $self->{'Purpose'} = $purpose;
    > > push {$self->{'Text'}}, $_ foreach $text;
    > > return $self;
    > > }
    >
    > Sorry, there was some wasted processing there.
    > # push {$self->{'Text'}}, $_ foreach $text;
    > $self->{'Text} = $text;
    Not really Joseph. Since $text is a passed-in array reference
    the array that it points to could be altered after the object
    has been built, so that the object's values would change.

    You don't have to puh the array elements one by one though. I'd
    do

    push {$self->{'Text'}}, $text;

    Cheers,

    Rob


    Rob Dixon Guest

Similar Threads

  1. 3D object oriented lingo
    By bgsBS in forum Macromedia Director 3D
    Replies: 1
    Last Post: July 25th, 11:46 AM
  2. Object Oriented Overkill ?
    By sonoflight in forum Coldfusion - Advanced Techniques
    Replies: 1
    Last Post: June 28th, 11:01 AM
  3. new enhanced object-oriented capabilities?
    By gumshoe in forum Macromedia ColdFusion
    Replies: 0
    Last Post: February 25th, 11:43 AM
  4. Object Oriented Web Design
    By Christian Cooper in forum ASP Components
    Replies: 2
    Last Post: May 9th, 08:14 AM
  5. oriented object programming
    By franck in forum PERL Miscellaneous
    Replies: 1
    Last Post: July 21st, 02:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139