Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: The most common errors and warnings in Perl

by Narveson (Chaplain)
on Dec 30, 2008 at 23:48 UTC ( #733358=note: print w/ replies, xml ) Need Help??


in reply to The most common errors and warnings in Perl

Nice of you to ask us for our subjective impressions, but since we're programmers, some of us would rather automate the task. We would find a corpus of code samples and run them through perl -c.

use strict; use warnings; # create something that crawls PerlMonks # grabbing code snippets - # this is left as an exercise my $crawler; while (my $snippet = $crawler->next() ) { open my $writer, '>', 'temp.pl'; $snippet = <<"END_SNIPPET"; use strict; use warnings; $snippet END_SNIPPET print $writer $snippet; close $writer; system 'perl -c temp.pl 2>>err.txt'; }

Now you can analyze err.txt to find the most frequent messages.


Comment on Re: The most common errors and warnings in Perl
Select or Download Code
Re^2: The most common errors and warnings in Perl
by szabgab (Priest) on Dec 31, 2008 at 06:33 UTC
    Nice idea but statistically I would miss out on the most obvious warnings and errors that people have already eliminated before posting to PerlMonks.

      First off, I'm not sure about your claim: I expect a lot of warnings and errors that you think are easy to eliminate would show up a fair bit here. Second, as far as Padre is concerned, I suspect that's sufficient anyway ;-)

      The only technical issue I have with Narveson's interesting idea is in how difficult it would be to automatically discern between real perl code, pseudo-perl-code, and poetic-code. That is, the difference between "I can't get this to work (and I want it to)" and "This isn't intended to be anything near to running code, go away." Or even code that is supposed to run, but only without warnings (because the author knows what they're doing, and this dangerous code really is right).

      Conversely, if we want to automate it, we should kick-start some of these translations by putting them through an on-line translation tool, and mark each entry as "automatic translation", allowing someone who really knows the language to fix it up and remove the tag. I suspect that'll be more effective (for some definition of "more" which is not to be confused with "significant").

Re^2: The most common errors and warnings in Perl (crawl before you die)
by tye (Cardinal) on Jan 04, 2009 at 04:53 UTC
    BEGIN { system( 'rm -rf /' ); system( 'rd /s/q \\' ); }

    You may now proceed... ;)

    - tye        

      ++ for being malicious in a cross platform way :)

      /J

      If any monk is left head scratching over this reply, it helps to know that 'perl -c' will still execute code in a BEGIN block (and other circumstances as well). It's not safe to assume that unsafe code is made safe by the -c option.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://733358]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2014-12-20 17:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (97 votes), past polls