Wednesday, March 4, 2009

Using the Modern::Perl module

I recently had a warning in the GUI version of twit.pl (work in progress):
v-string in use/require non-portable at C:\Perl\usr\Blog\twit_1_0_0.pl line 73

The incriminated line 73 was:
use 5.10.0;

I googled the error string and Tom Wyant's ticket on Perl came up. It helped me understand the issue at hand and how to fix it.
However, for more in-depth information, I pushed my way to perldoc.perl.org

v-string refers to a version string: be warned, the version strings have ben deprecated since Perl 5.8.1 and this is why you will get a warning.
Version strings start with a "v" (example: v1.0). Strings that have 2 decimal points (eg. v1.0.0) are automatically considered as version strings.

In Perl, you can use underscores in numeric values between digits to make them easier to read.
For example, 1200.0053 can be represented as 1_200.00_53.

To remove the v-string warning, I replaced the line
use 5.10.0;
by
use 5.010_000;

(use 5.010 also works but not use 5.10: the Perl compiler will look for version 5.100)

Or you can also use the Modern::Perl module written by chromatic.
Among other things, Modern::Perl will include the following pragmas:

use 5.010_000;
use strict;
use warnings;

In order to install the module from Padre, all is required is that you go to:
Perl>Install Module...>Install CPAN Module
You will see the window below:

perl::critic module install from Padre
Enter Modern::Perl and let CPAN work its magic!

Larry Wall quote of the day:
"Perl itself is usually pretty good about telling you what you shouldn't do."

Possible next posts:
  • Perl template - Part II: Adding Help and Version procedures
  • Perl help resources
  • Improving on twit.pl: Graphical User interface
  • POD
  • Install Google Analytics on your Blogger blog and stats for DLP

No comments :

Post a Comment