Normally if you receive an error or warning from perl you can either put use diagnostics; in your code to get a more detailed explanation or you can save the error message in a file perl my_script.pl > err.txt and then run splain err.txt to get the relevant explanation from perldiag
With the latest release of Padre you can get translated version of this diagnostics message when you run your code from Padre. Actually it is a bit virtual claim as so far we only found a French translation of the perldiag.pod file in POD2::FR.
So I would like to encourage others to start translating the perldiag messages and uploading POD2::Your_Language to CPAN but that's quite a lot of work so I'd like to help people focus on the most common errors and warnings one might receive. Translating those would go a long way in helping people who are new to Perl and are not well prepared in English either.
So I'd like to collect a set of example scripts along with the error messages or warnings they generate. Let me show what I have so far:
hello with warn
Gives two:#!/usr/bin/perl use strict; use warnings; my $name; print "Hello $name\n"; my $x = "2x"; print 3+$x; print "done\n";
Use of uninitialized value $name in concatenation (.) or string at t/f +iles/hello_with_warn.pl line 7 Argument "2x" isn't numeric in addition (+) at t/files/hello_with_warn +.pl line 9.
no strict
gives#!/usr/bin/perl use warnings; $what = 42;
Name "main::what" used only once: possible typo at t/files/no_strict.p +l line 4.
Missing semicolon
gives#!/usr/bin/perl use strict; use warnings; my $x if ($x) { print "ok"; }
Global symbol "$x" requires explicit package name at t/files/missing_s +emicolon.pl line 7. syntax error at t/files/missing_semicolon.pl line 7, near ") {" Execution of t/files/missing_semicolon.pl aborted due to compilation e +rrors.
What else?
This is the list I came up with. I'd like to get your other examples for what you think are the most common error messages and warnings.
Once you are done with that, I'd like to ask you to go and translate the relevant entries in perldiag and upload the first version of POD2::Your_Language to CPAN. While this is not Padre specific, if you need an SVN server for cooperating with others, we'd be glad to provide space for this on the SVN server of Padre.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: The most common errors and warnings in Perl
by rir (Vicar) on Dec 30, 2008 at 14:22 UTC | |
Re: The most common errors and warnings in Perl
by Narveson (Chaplain) on Dec 30, 2008 at 23:48 UTC | |
by tye (Sage) on Jan 04, 2009 at 04:53 UTC | |
by kyle (Abbot) on Jan 04, 2009 at 16:14 UTC | |
by jplindstrom (Monsignor) on Jan 04, 2009 at 16:08 UTC | |
by szabgab (Priest) on Dec 31, 2008 at 06:33 UTC | |
by Tanktalus (Canon) on Jan 04, 2009 at 04:14 UTC |