Believers in the Perl Faith!


Almost a year ago I offered the materialization of my Perl worshiping in this CUFP posting about Perl code generation with PerlBean.

Two months ago I submitted version 1.0 of PerlBean to CPAN and I rejoice to be able to say that PerlBean works for me (at least.)

Action speaks louder than words so I'll mention two general purpose packages I offered to the public which I developed using PerlBean:
In my previous posting (see link above) I already summarized PerlBean. Most importantly it still saves me a great deal of time when writing Perl code.

I improved on all the points I mentioned and I even found quite a few more areas to improve. See the BUGS section of PerlBean documentation (NOTE: The link at the top seems to be broken).
You can find the tutorial over here.

Again I hope PerlBean may be useful to other Perl programmers.


Yours,
Vincenzo Zocca
Vincenzo@Zocca.no.spam.com
remove no.spam to contact me
  • Comment on Perl code generation with PerlBean (continued)

Replies are listed 'Best First'.
Re: Perl code generation with PerlBean (continued)
by pinetree (Scribe) on Nov 03, 2003 at 16:24 UTC

    Vincenzo,
    Very nice. I was looking through the decumentation and have a suggested change for your diagram "2.1 Class diagram for shapes".

    I would change the order of the square and rectangle. A square is always a rectangle but a rectangle is not always a square...

    Oren
      Hi Oren,

      There's a great deal of iron in your words of making me see common sense. Thanks for them.

      When I wrote the tutorial I was concentrating on properties/attributes -square's have one significant dimension and rectangles have two- and I overlooked the actual meaning of the object hierarchy. Silly me.

      I will correct this in a next release. However, I don't have a release plan yet as I'm concentrating on producing more code with PerlBean to collect ideas for improvement.

      Vincenzo
Re: Perl code generation with PerlBean (continued)
by Jaap (Curate) on Nov 04, 2003 at 11:20 UTC
    Looking at this pice of code:
    # Make the Circle area() method add it to the Circle PerlBean use PerlBean::Method; my $area_circle = PerlBean::Method->new( { method_name => 'area', body => <<EOF, my \$self = shift; return( 2 * 3.1415926 * \$self->get_radius() ); EOF } ); $circle->add_method( $area_circle );
    If you use <<'EOF' you don't have to escape the scalars, which might be handy.

    Secondly, doesn't your module generate the always-present my $self = shift?
      Hi Jaap,

      If you use <<'EOF' you don't have to escape the scalars, which might be handy.
      I know. I used a lot of <<EOF in PerlBean itself to actually have the variables resolved in the text. E.g. for package names, subroutine names etc... Without giving it too much of a thought I simply went on with this in the tutorial.

      In this case too, the same change policy as the one I unfolded to Oren will apply.

      You can of course speed up development by fast-forwarding to section 10 of the tutorial :)

      Vincenzo
      Secondly, doesn't your module generate the always-present my $self = shift?
      • Remember that most methods are fully generated by PerlBean -with the my $self line. Typically, you'd write yourself as few as possible methods (the fun ones, and not the boring ones of course.)
      • You don't always need my $self. For instance for static methods.
      • It's not that much work to type yank a my $self = shift; line from another method.
      • As it's not too much work making this the default behavior for empty methods, I could. Then again, what would be the purpose of an empty method?
      Vincenzo
Re: Perl code generation with PerlBean (continued)
by Jaap (Curate) on Nov 04, 2003 at 11:24 UTC
    And yet anothe comment on the documentation: ;)
    # Remove the old directory system ("rm -rf $dir");
    where possible, use perl's built-in functions, in this case unlink. This has 2 advantages:
    1. Works on windows and other OS's too
    2. No need to start a new shell/process thingy (althoug this does not always happen with system())