Click here to get back home

code written under 5.10.0 to be run under 5.8.8

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
code written under 5.10.0 to be run under 5.8.8 dummy 05-10-2008
Posted by dummy on May 10, 2008, 11:51 pm
Please log in for more thread options
I understand that one can specify that a script must be run under a perl
version no earlier than a particular version. So, if I say 'use 5.6.0',
that code will throw an error if one tries to run it under perl 5.5.0,
right?

But how about the reverse case?

Suppose I write code on my desktop, which has perl 5.10.0 installed, and
later transfer that code to a system that only has perl as far as 5.8.8.
How can I cause an error on the desktop if I accidentally use any of the
new features of 5.10.0, as I would want to do to signal incompatibility?
Is this sort of thing impossible?


Posted by Ben Bullock on May 11, 2008, 7:06 am
Please log in for more thread options
On Sat, 10 May 2008 20:51:54 -0700, dummy wrote:

> I understand that one can specify that a script must be run under a perl
> version no earlier than a particular version. So, if I say 'use 5.6.0',
> that code will throw an error if one tries to run it under perl 5.5.0,
> right?

#!/usr/local/bin/perl

use warnings;

use 5.6.0;

v-string in use/require non-portable at ./usenet-2008-5-11.pl line 5.

So you have to say

use 5.006;

> But how about the reverse case?
>
> Suppose I write code on my desktop, which has perl 5.10.0 installed, and
> later transfer that code to a system that only has perl as far as 5.8.8.
> How can I cause an error on the desktop if I accidentally use any of the
> new features of 5.10.0, as I would want to do to signal incompatibility?

> Is this sort of thing impossible?

I believe the new features are all turned off by default anyway, so you
have to "use 5.010;" anyway:

#!/usr/local/bin/perl

use warnings;

use 5.010;

say "say say what you want";

Posted by dummy on May 11, 2008, 5:37 pm
Please log in for more thread options
On Sun, 11 May 2008 11:06:21 +0000 (UTC), Ben Bullock

>On Sat, 10 May 2008 20:51:54 -0700, dummy wrote:
>
>> I understand that one can specify that a script must be run under a perl
>> version no earlier than a particular version. So, if I say 'use 5.6.0',
>> that code will throw an error if one tries to run it under perl 5.5.0,
>> right?
>
>#!/usr/local/bin/perl
>
>use warnings;
>
>use 5.6.0;
>
>v-string in use/require non-portable at ./usenet-2008-5-11.pl line 5.
>
>So you have to say
>
>use 5.006;
>
>> But how about the reverse case?
>>
>> Suppose I write code on my desktop, which has perl 5.10.0 installed, and
>> later transfer that code to a system that only has perl as far as 5.8.8.
>> How can I cause an error on the desktop if I accidentally use any of the
>> new features of 5.10.0, as I would want to do to signal incompatibility?
>
>> Is this sort of thing impossible?
>
>I believe the new features are all turned off by default anyway, so you
>have to "use 5.010;" anyway:
>
>#!/usr/local/bin/perl
>
>use warnings;
>
>use 5.010;
>
>say "say say what you want";

Thank you; I do need to specify the 5.10.0 features. But I can use
either 5.10.0 or 5.010 to do so. At least on my system, using
strawberry; see below. Why is it different for you?

------ start quote -----
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

c:\>perl
say "hi";
String found where operator expected at - line 1, near "say "hi""
(Do you need to predeclare say?)
^D
syntax error at - line 1, near "say "hi""
Execution of - aborted due to compilation errors.

c:\>perl
use 5.10.0;
say "hi";
^D
hi

c:\>perl
use 5.010;
say "hi"
^D
hi

c:\>perl
use 5.6.0;
print "hi\n";
^D
hi

c:\>

----------- end quote




Posted by Michael Carman on May 11, 2008, 8:36 pm
Please log in for more thread options
dummy@phony.info wrote:
> Thank you; I do need to specify the 5.10.0 features. But I can use
> either 5.10.0 or 5.010 to do so. At least on my system, using
> strawberry; see below. Why is it different for you?

It isn't, but "5.010" is backwards compatible with even very old
versions of Perl. The version string "5.10.0" is only recognized
starting with Perl version 5.6.

For the more general case there's the module Perl::MinimumVersion which
attempts to scan your source code and determine the minimum version of
Perl that is needed to run it. It's still in early development though.

Personally, I keep a cheat-sheet of which things (that I commonly use)
were added with each version of Perl. I created it by reading through
the perldelta pages in perldoc.

-mjc

Posted by Uri Guttman on May 12, 2008, 1:00 pm
Please log in for more thread options

wrote:
>> On Sun, 11 May 2008 11:06:21 +0000 (UTC), Ben Bullock
>>> I believe the new features are all turned off by default anyway, so you
>>> have to "use 5.010;" anyway:
>>
>> On what versions of perl5 do you believe has new features off by default?

PJH> In 5.10 you have to explicitely enable new features by adding a
PJH> "use 5.010;" line.

PJH> It depends on your programming style, of course. For my code it is safe
PJH> to assume that it won't run with Perl 5.6.x or older unless I specially
PJH> took care to make it portable. There were a lot of nifty features added
PJH> in 5.8 and I am using them.

i haven't played with 5.10 yet and 5.8 didn't make major syntax
improvements that i want (though it is the default version i generally
use). but for some of my cpan modules (file::slurp) in particular) i
work hard to keep it backwards compatible all the way back to 5.005 (and
i think even 5.004). this is because it is a very popular module and
there are still too many places where old perl's lurk. i wouldn't do
this for any production code where i know the perl version is recent but
i can't control that when someone uses a module.

uri

--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------

Similar ThreadsPosted
rsh daemon written in perl? December 12, 2004, 11:14 pm
new commands written in perl September 21, 2004, 11:57 am
Can services be written in Perl? December 14, 2005, 9:31 pm
Can device drivers be written in Perl? December 9, 2005, 9:55 pm
General way to run an exe with errors written to a file September 19, 2007, 8:04 pm
is there a minimal LDAP server written in Perl? April 13, 2005, 4:12 pm
How to port scripts written for UNIX on windows June 1, 2005, 5:59 am
Can (nearly) any Perl program be written on a single line? October 19, 2005, 5:30 pm
ID3 Tags written by Perl can not be modified by any other ID3 editor December 19, 2005, 7:33 am
A simple photosharing application written in perl April 21, 2007, 3:45 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap