Hello Monks

I am new here, and was wondering if this is the type of site where I could submit a functional program, but a very crude one (I'm new to Perl and programming). I want some feedback on how to clean it up/ become aware of potential errors/ hear advice on a better methods etc...

If so, would this go into Seekers of Perl Wisdom?? Is it frowned upon? Is there a limit to size of code?

Thanks a lot!

  • Comment on Beginner: Desire Code Review/ clean-up??

Replies are listed 'Best First'.
Re: Beginner: Desire Code Review/ clean-up??
by Your Mother (Archbishop) on Jun 10, 2011 at 17:38 UTC
Re: Beginner: Desire Code Review/ clean-up??
by toolic (Bishop) on Jun 10, 2011 at 16:49 UTC
    I think Meditations would be an appropriate section:
    Meditations is sometimes used as a sounding-board — a place to post initial drafts of perl tutorials, code modules, book reviews, articles, quizzes, etc. — so that the author can benefit from the collective insight of the monks before publishing the finished item to its proper place (be it Tutorials, Cool Uses for Perl, Reviews, or whatever). If you do this, it is generally considered appropriate to prefix your node title with "RFC:" (for "request for comments").

    Regarding code size... my feeling is that the more lines of code you have, the fewer people will look at it.

      Yes, but I think SoPW is still better for code reviews. Meditations is more like "Here's some thoughts I had and wanted to share. Constructive feedback is welcome, of course." SoPW is as appropriate for seeking wisdom on a 1000-line code module as it is on a 1-line snippet.

      I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.
Re: Beginner: Desire Code Review/ clean-up??
by davido (Cardinal) on Jun 10, 2011 at 17:22 UTC

    Start with a description of the input and the desired output. Give a brief description of your code outline. Then if you have specific areas in which you need clarification post those portions of the code. The more you're able to reduce the amount of code posted, the greater the response will be, and the more targeted it will be to the areas where you feel you have the most need.


    Dave

Re: Beginner: Desire Code Review/ clean-up??
by fisher (Priest) on Jun 15, 2011 at 16:20 UTC
    I agree with jdporter, but don't forget about the <readmore> tag.
Re: Beginner: Desire Code Review/ clean-up??
by Anonymous Monk on Jun 15, 2011 at 16:27 UTC
    We've had these before, they went in SOPW
Re: Beginner: Desire Code Review/ clean-up??
by Khen1950fx (Canon) on Jun 16, 2011 at 11:24 UTC
    Here's a little script that will help you cleanup. To use it, do:
    this_script.pl /script/to/cleanup
    And the script:
    #!/usr/bin/perl use strict; use warnings; my $file = shift @ARGV; open STDOUT, '>', '/root/Desktop/squish.log'; use PPI; use Perl::Squish; my $Document = PPI::Document->new($file); $Document->prune('PPI::Token::Comment'); $Document->prune( sub { my $Braces = $_[1]; $Braces->isa('PPI::Structure::List') or return ''; $Braces->children == 0 or return ''; my $Method = $Braces->sprevious_sibling or return ''; $Method->isa('PPI::Token::Word') or return ''; $Method->content !~ /:/ or return ''; my $Operator = $Method->sprevious_sibling or return ''; $Operator->isa('PPI::Token::Operator') or return ''; $Operator->content eq '->' or return ''; return 1; } ); my $Normal = $Document->normalized(2); print $Document;