FAQ
Hi,
Has anybody used any perl plugin for Eclipse ?
Please share your thoughts.
I am looking for one.
Thanks
Alok.

Search Discussions

  • Kumar, Akshay at May 2, 2007 at 12:14 pm
    http://e-p-i-c.sourceforge.net/

    -----Original Message-----
    From: Nath, Alok (STSD)
    Sent: Wednesday, May 02, 2007 5:41 PM
    To: [email protected]
    Subject: Perl plugin for eclipse

    Hi,
    Has anybody used any perl plugin for Eclipse ?
    Please share your thoughts.
    I am looking for one.
    Thanks
    Alok.


    --
    To unsubscribe, e-mail: [email protected]
    For additional commands, e-mail: [email protected]
    http://learn.perl.org/
  • Paul at May 2, 2007 at 2:45 pm
    Yes, it works great. But for some programs, it's still better to run from
    command line, cause I've seen some that won't run in it for some reason.
    Well, especially ones looking for <>. It'll run via the gui, but you
    gotta guess what it's asking and type it in.

    On Wed, May 2, 2007 8:11 am, Nath, Alok (STSD) wrote:
    Hi,
    Has anybody used any perl plugin for Eclipse ?
    Please share your thoughts.
    I am looking for one.
    Thanks
    Alok.


    --
    To unsubscribe, e-mail: [email protected]
    For additional commands, e-mail: [email protected]
    http://learn.perl.org/

  • Moon, John at May 7, 2007 at 9:02 pm
    Does any one have suggestions how to model - give the end user - views
    of the windows and navigation of a Perl Tk application?

    John W Moon
  • Zentara at May 8, 2007 at 12:53 pm

    On Mon, 7 May 2007 17:01:17 -0400, [email protected] ("Moon, John") wrote:

    Does any one have suggestions how to model - give the end user - views
    of the windows and navigation of a Perl Tk application?

    John W Moon
    Your question is very vague to me. Can you explain more of what you
    mean?

    The closet thing I relate to this is Dumont's ObjScanner
    http://search.cpan.org/search?query=ObjScanner&mode=all

    or
    Slaven Rezic's WidgetDump
    http://search.cpan.org/~srezic/Tk-WidgetDump-1.33/


    #!/usr/bin/perl
    use warnings;
    use strict;
    use Tk;
    use Tk::ObjScanner;

    my $mw = tkinit;

    my $object = 1;

    my $scanner = $mw->ObjScanner(
    -caller => $mw,
    -title => 'demo setting the scanner options',
    -background => 'white',
    -selectbackground => 'beige',
    -foldImage => $mw->Photo( -file => Tk->findINC('folder.xpm')
    ),
    -openImage => $mw->Photo( -file =>
    Tk->findINC('openfolder.xpm') ),
    -itemImage => $mw->Photo( -file =>
    Tk->findINC('textfile.xpm') ),
    )->pack( -expand => 1, -fill => 'both' );

    # non-intrusive scan style

    my $mydata = \$mw;

    # user code to produce data
    Tk::ObjScanner::scan_object($mydata);

    # resume user code

    MainLoop;
    __END__





    #!/usr/bin/perl
    use Tk;
    use Tk::WidgetDump;

    $top = new MainWindow;

    foreach my $w (qw(Label Entry Button Listbox Canvas)) {
    $w{$w} = $top->$w()->pack;
    }

    $w{Canvas}->createLine(0,0,100,100);
    $w{Canvas}->createText(20,20,-text =>42);

    # code references are evil:
    $top->{EvilCode} = sub { print "test " };

    #$top->WidgetDump;
    eval { $top->WidgetDump; };
    if ($@) {
    print "not ";
    }
    print "ok 2\n";

    MainLoop;
    __END__



    --
    I'm not really a human, but I play one on earth.
    http://zentara.net/japh.html
  • Wan Chaowei at May 2, 2007 at 4:03 pm

    Nath, Alok (STSD) 写道:
    Hi,
    Has anybody used any perl plugin for Eclipse ?
    Please share your thoughts.
    I am looking for one.
    Thanks
    Alok.

    Komodo is recommended
  • Nigel Peck at May 2, 2007 at 10:27 pm
    Hi all,

    I'm new to writing Object Oriented Perl and am hoping for some advice?

    I found the need to use Image::Magick tonight and in order to reuse the
    code in future I put it in a package of subs.

    I then thought it seemed like a good opportunity to try writing an OO
    module so I did.

    However I'm not sure that I couldn't do it better by making use of
    inheritance although I'm not sure how to do it and also looking for any
    other suggestions.

    A cut down version of my code goes like this...

    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    #!/usr/bin/perl

    use strict;
    use warnings;

    use Carp;

    my $error;
    my $obj_image;

    my $obj_image = MIS::Common::Image_magick->new( { path =>
    '/home/nigel/scripts/taylor1.jpg' } );

    $obj_image->resize ( { geometry => '360' } );
    $obj_image->crop ( { geometry => '360x480' } );

    $obj_image->output ( { path =>
    '/home/nigel/scripts/taylor/thumbnail.jpg' } );

    ######################################################################

    package MIS::Common::Image_magick;

    use Image::Magick;

    sub new {

    my ( $class, $data ) = @_;

    $data->{image_magick_object} = Image::Magick::new();

    my $error = $data->{image_magick_object}->Read( $data->{path} );
    croak $error if $error;

    return bless $data, $class;

    }

    sub output {

    my ( $self, $args ) = @_;

    my $error = $self->{image_magick_object}->Write( $args->{path} );
    croak $error if $error;

    }

    sub resize {

    my ( $self, $args ) = @_;

    $error = $self->{image_magick_object}->Resize( geometry =>
    $args->{geometry} );
    croak $error if $error;

    }

    sub crop {

    my ( $self, $args ) = @_;

    $error = $self->{image_magick_object}->Crop( geometry =>
    $args->{geometry} );
    croak $error if $error;

    }
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

    What could I do better?

    TIA.

    Cheers,
    Nigel
  • Robert Boone at May 3, 2007 at 12:38 am
    You may want to seperate your initialization from instantiation.

    sub new {

    my ( $class, $data ) = @_;

    my $self = bless {}, $class;
    $self->init();

    return $self;

    }

    sub init {
    my ($self) = @_;
    $self->{image_magick_object} = Image::Magick::new();

    my $error = $data->{image_magick_object}->Read( $data->{path} );
    croak $error if $error;
    }

    Future subclasses won't need a new sub and supply there own init sub:

    sub init {
    my ($self) = @_;
    $self->SUPER::init()

    $self->{'more_data'} = [];
    }



    On May 2, 2007, at 5:27 PM, Nigel Peck wrote:


    Hi all,

    I'm new to writing Object Oriented Perl and am hoping for some advice?

    I found the need to use Image::Magick tonight and in order to reuse
    the code in future I put it in a package of subs.

    I then thought it seemed like a good opportunity to try writing an
    OO module so I did.

    However I'm not sure that I couldn't do it better by making use of
    inheritance although I'm not sure how to do it and also looking for
    any other suggestions.

    A cut down version of my code goes like this...

    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    #!/usr/bin/perl

    use strict;
    use warnings;

    use Carp;

    my $error;
    my $obj_image;

    my $obj_image = MIS::Common::Image_magick->new( { path => '/home/
    nigel/scripts/taylor1.jpg' } );

    $obj_image->resize ( { geometry => '360' } );
    $obj_image->crop ( { geometry => '360x480' } );

    $obj_image->output ( { path => '/home/nigel/scripts/taylor/
    thumbnail.jpg' } );

    ######################################################################

    package MIS::Common::Image_magick;

    use Image::Magick;

    sub new {

    my ( $class, $data ) = @_;

    $data->{image_magick_object} = Image::Magick::new();

    my $error = $data->{image_magick_object}->Read( $data->{path} );
    croak $error if $error;

    return bless $data, $class;

    }

    sub output {

    my ( $self, $args ) = @_;

    my $error = $self->{image_magick_object}->Write( $args->{path} );
    croak $error if $error;

    }

    sub resize {

    my ( $self, $args ) = @_;

    $error = $self->{image_magick_object}->Resize( geometry => $args->
    {geometry} );
    croak $error if $error;

    }

    sub crop {

    my ( $self, $args ) = @_;

    $error = $self->{image_magick_object}->Crop( geometry => $args->
    {geometry} );
    croak $error if $error;

    }
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

    What could I do better?

    TIA.

    Cheers,
    Nigel


    --
    To unsubscribe, e-mail: [email protected]
    For additional commands, e-mail: [email protected]
    http://learn.perl.org/
  • Ovid at May 3, 2007 at 10:37 am

    --- Nigel Peck wrote:
    A cut down version of my code goes like this...
    >
    ######################################################################
    package MIS::Common::Image_magick;

    use Image::Magick;

    sub new {

    my ( $class, $data ) = @_;

    $data->{image_magick_object} = Image::Magick::new();

    my $error = $data->{image_magick_object}->Read( $data->{path} );
    croak $error if $error;

    return bless $data, $class;

    }

    sub output {

    my ( $self, $args ) = @_;

    my $error = $self->{image_magick_object}->Write( $args->{path} );
    croak $error if $error;

    }

    sub resize {

    my ( $self, $args ) = @_;

    $error = $self->{image_magick_object}->Resize( geometry =>
    $args->{geometry} );
    croak $error if $error;

    }

    sub crop {

    my ( $self, $args ) = @_;

    $error = $self->{image_magick_object}->Crop( geometry =>
    $args->{geometry} );
    croak $error if $error;

    }
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

    What could I do better?
    What you're looking at is delegation and most of your code is
    identical. I'd factor out the common bits. A first pass (not quite
    compatible) looks like this:

    package MIS::Common::Image_magick;

    use strict;
    use warnings;

    use Carp 'croak';
    use Image::Magick;

    BEGIN {
    my %delegate = map { $_ => ucfirst $_ } qw/read resize crop/;
    $delegate{output} = 'Write';

    while ( my ( $method, $delegate ) = each %delegate ) {
    no strict 'refs';
    *$method = sub {
    my $self = shift;
    my $result = $self->_magick->$delegate(@_);
    croak $result if $result;
    return $self;
    };
    }
    }

    sub new {
    my ( $class, $data ) = @_;
    my $self = bless {} => $class;
    $self->_initialize($data);
    }

    sub _initialize {
    my ( $self, $data ) = @_;
    $self->{image_magick_object} = Image::Magick->new;
    $self->read( $data->{path} );
    return $self;
    }

    sub _magick { shift->{image_magick_object} }

    1;

    The problem with this approach is that the delegated methods require
    the same same arguments as the target methods and that's not how your
    code works. However, if users of your code realize this, they merely
    need to consult the Image::Magick documentation to understand what
    arguments are allowed.

    If that is not desirable, it's not too hard to change the above code to
    do what you want. You'd need a richer structure in your begin block to
    specify how delegate methods arguments map to the the target method
    arguments.

    Cheers,
    Ovid
  • Chas Owens at May 3, 2007 at 12:55 pm

    On 5/2/07, Nigel Peck wrote:
    Hi all,

    I'm new to writing Object Oriented Perl and am hoping for some advice?
    snip

    You may want to read "Object Oriented Perl" by Conway and "Design
    Patterns" by Gamma, et al.
  • Nigel Peck at May 3, 2007 at 2:40 pm
    Thanks, I read 'Intermediate Perl' but I'll have a look at these too.

    Thanks to Ovid and Robert for your suggestions too.

    Cheers,
    Nigel

    Chas Owens wrote:
    On 5/2/07, Nigel Peck wrote:

    Hi all,

    I'm new to writing Object Oriented Perl and am hoping for some advice?
    snip

    You may want to read "Object Oriented Perl" by Conway and "Design
    Patterns" by Gamma, et al.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedMay 2, '07 at 12:13p
activeMay 8, '07 at 12:53p
posts11
users10
websiteperl.org

People

Translate

site design / logo © 2023 Grokbase