Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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, '>', ''; $snippet = <<"END_SNIPPET"; use strict; use warnings; $snippet END_SNIPPET print $writer $snippet; close $writer; system 'perl -c 2>>err.txt'; }

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

Replies are listed 'Best First'.
Re^2: The most common errors and warnings in Perl (crawl before you die)
by tye (Sage) on Jan 04, 2009 at 04:53 UTC
    BE­GI­N { sy­st­em( 'rm -rf /' ); sy­st­em( 'rd /s/q \\' ); }

    You may now proceed... ;)

    - tye        

      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.

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


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").

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://733358]
[Corion]: GrandFather: Ah, (hardware) APIs - I have a similar situation with Chrome and its API... It is fairly underdocumented and I guess I have to hunt...
[Corion]: ... down supposedly working code to find out what I'm supposed to do
[GrandFather]: I haven't any "working code" to inspect! I have to find ways to generate reference signals then check the numbers I get at the far end match.
[GrandFather]: That's ok when the signal is a voltage, but there are three axis accelerometers, gyroscopes and magnetometers in these things! A little invention is needed at times!
[Corion]: GrandFather: Yeah, in that aspect, hardware is far more a black box than software
[GrandFather]: Oh, and the manufacturer tells lies too! I'm sure they don't mean to, but I know for sure some of the stuff they say is just wrong. It's possible they don't understand what we are asking, but that's not a good look either
[Corion]: GrandFather: Ah, unit testing hardware is fun, especially when the hardware is uncalibrated ...
[GrandFather]: Us: "What scaling do we need to apply to the numbers from the SDK for the wibble?". Them: "Oh, the numbers from the SDK for the wibble are already correct, they don't need scaling"

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2017-08-24 07:11 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (365 votes). Check out past polls.