Google Groups Home
Help | Sign in
code written under 5.10.0 to be run under 5.8.8
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  18 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
du...@phony.info  
View profile
 More options May 10, 11:51 pm
Newsgroups: comp.lang.perl.misc
From: du...@phony.info
Date: Sat, 10 May 2008 20:51:54 -0700
Local: Sat, May 10 2008 11:51 pm
Subject: code written under 5.10.0 to be run under 5.8.8
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?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ben Bullock  
View profile
 More options May 11, 7:06 am
Newsgroups: comp.lang.perl.misc
From: Ben Bullock <benkasminbull...@gmail.com>
Date: Sun, 11 May 2008 11:06:21 +0000 (UTC)
Local: Sun, May 11 2008 7:06 am
Subject: Re: code written under 5.10.0 to be run under 5.8.8

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";


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
du...@phony.info  
View profile
 More options May 11, 5:37 pm
Newsgroups: comp.lang.perl.misc
From: du...@phony.info
Date: Sun, 11 May 2008 14:37:52 -0700
Local: Sun, May 11 2008 5:37 pm
Subject: Re: code written under 5.10.0 to be run under 5.8.8
On Sun, 11 May 2008 11:06:21 +0000 (UTC), Ben Bullock

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Carman  
View profile
 More options May 11, 8:36 pm
Newsgroups: comp.lang.perl.misc
From: Michael Carman <mjcar...@mchsi.com>
Date: Mon, 12 May 2008 00:36:35 GMT
Local: Sun, May 11 2008 8:36 pm
Subject: Re: code written under 5.10.0 to be run under 5.8.8

du...@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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sir Robin  
View profile
 More options May 12, 4:45 am
Newsgroups: comp.lang.perl.misc
From: Sir Robin <rob...@NO-SPAM-REMOVE-THIS.fiveam.org>
Date: Mon, 12 May 2008 11:45:59 +0300
Local: Mon, May 12 2008 4:45 am
Subject: Re: code written under 5.10.0 to be run under 5.8.8
On Sun, 11 May 2008 11:06:21 +0000 (UTC), Ben Bullock

<benkasminbull...@gmail.com> wrote:
>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? I
have always studied simply just perl5 programming and I have so far never
bumped in situation where my version of perl did not have some feature I use
off by default or feature of newer perl version and I have never paid
attention on if something I learn and then use is feature in perl5 version
newer than this or that so I don't know where to even look for if my code has
any other requirements than that it's not older than perl5 that is used to run
it...

If there is any program available that can check through piece of code and
report any features that are new features of some subversion of perl5 and list
those it finds with of course the version of perl5 that has the feature?

Or am I safe to assume that users with older perl5 version that I have tested
my code with can run my program if I dont have any "use 5.xxx;" line and the
script runs fine?

--
***/---   Sir Robin (aka Jani Saksa) Bi-Sex and proud of it!     ---\***
**/  email: rob...@fiveam.NO-SPAM.org, <*> Reg. Linux user #290577   \**
*| Me, Drugs, DooM, Photos, Writings... http://soul.fiveam.org/robsku |*
**\---                 GSM/SMS: +358 44 927 3992                  ---/**
"Jokainen linkki, jonka päätteenä on ".org", on kelvoton tiedonlähde."
- Nikolas Mäki


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter J. Holzer  
View profile
 More options May 12, 6:51 am
Newsgroups: comp.lang.perl.misc
From: "Peter J. Holzer" <hjp-usen...@hjp.at>
Date: Mon, 12 May 2008 12:51:25 +0200
Local: Mon, May 12 2008 6:51 am
Subject: Re: code written under 5.10.0 to be run under 5.8.8
On 2008-05-12 08:45, Sir Robin <rob...@NO-SPAM-REMOVE-THIS.fiveam.org> wrote:

> On Sun, 11 May 2008 11:06:21 +0000 (UTC), Ben Bullock
><benkasminbull...@gmail.com> wrote:
>>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?

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

> I have always studied simply just perl5 programming and I have so far
> never bumped in situation where my version of perl did not have some
> feature I use off by default or feature of newer perl version and I
> have never paid attention on if something I learn and then use is
> feature in perl5 version newer than this or that so I don't know where
> to even look for if my code has any other requirements than that it's
> not older than perl5 that is used to run it...

I take a pragmatic approach there. I just write my programs for whatever
version of Perl I have available. When I notice that it doesn't work on
some older version (that's what test suites are for - among other
things) I either fix it or add a "use 5.xxx" for the oldest version
where it is known to work.

> If there is any program available that can check through piece of code and
> report any features that are new features of some subversion of perl5 and list
> those it finds with of course the version of perl5 that has the feature?

> Or am I safe to assume that users with older perl5 version that I have tested
> my code with can run my program if I dont have any "use 5.xxx;" line and the
> script runs fine?

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

I haven't started using 5.10 features yet. All of my servers have some
variant of 5.8.x installed, and until a significant portion of them has
been upgraded to 5.10.x (which I expect to come with the next release
of RHEL and Debian - but we won't upgrade all our servers immediately
even then) using 5.10 features is just a waste of time.

        hp


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Uri Guttman  
View profile
 More options May 12, 1:00 pm
Newsgroups: comp.lang.perl.misc
From: Uri Guttman <u...@stemsystems.com>
Date: Mon, 12 May 2008 17:00:43 GMT
Local: Mon, May 12 2008 1:00 pm
Subject: Re: code written under 5.10.0 to be run under 5.8.8

>>>>> "PJH" == Peter J Holzer <hjp-usen...@hjp.at> writes:

  PJH> On 2008-05-12 08:45, Sir Robin <rob...@NO-SPAM-REMOVE-THIS.fiveam.org> wrote:
  >> On Sun, 11 May 2008 11:06:21 +0000 (UTC), Ben Bullock
  >> <benkasminbull...@gmail.com> wrote:
  >>> 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  ------  u...@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 ---------


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Abigail  
View profile
 More options May 12, 2:37 pm
Newsgroups: comp.lang.perl.misc
From: Abigail <abig...@abigail.be>
Date: 12 May 2008 18:37:29 GMT
Local: Mon, May 12 2008 2:37 pm
Subject: Re: code written under 5.10.0 to be run under 5.8.8
                                             _
du...@phony.info (du...@phony.info) wrote on VCCCLXVII September MCMXCIII
in <URL:news:0gqc245d164jqt67qo69ho0lif7i1f7clv@4ax.com>:
<>  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?

The reverse case is pretty easy:

    BEGIN {
        die "Your Perl version is too new" if $] > 5.008008;
    }

<>  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?

That's not the reverse case.

<>  Is this sort of thing impossible?

Basically, yes. There are some new features that aren't available unless
turned on explicitely, but that isn't the case for features that will not
cause any backwards compatability issues. For instance, there are a ton of
new features when using regexpes, and you get them regardless whether you
use "use feature" or not. Furthermore, bug fixes will be there as well, and
so will any modules that are in 5.010, but not in an older install of Perl.

The best way to avoid accidentily using features that aren't available on
older Perl is to install the oldest Perl you want to develop for, and test
with that.

Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^ W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$ ^V
%$^U;$^V/=$^U}while$^V!=$^W'


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
szr  
View profile
 More options May 12, 8:43 pm
Newsgroups: comp.lang.perl.misc
From: "szr" <sz...@szromanMO.comVE>
Date: Mon, 12 May 2008 17:43:51 -0700
Local: Mon, May 12 2008 8:43 pm
Subject: Re: code written under 5.10.0 to be run under 5.8.8

Yes, that seems to work:

   $ perl5.10.0 -e 'print $]'
   5.010000
   $ perl5.8.8 -e 'print $]'
   5.008008
   $ perl5.8.2 -e 'print $]'
   5.008002
   $ perl5.8.0 -e 'print $]'
   5.008
   $ perl5.6.1 -e 'print $]'
   5.006001

Little question: Since this is a floating point number, are there any
rounding-error considerations when making comparisons and such?

Also, is there a reason why 5.10's output pads zeros on the right-hand
end of the number?

--
szr


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Uri Guttman  
View profile
 More options May 12, 8:49 pm
Newsgroups: comp.lang.perl.misc
From: Uri Guttman <u...@stemsystems.com>
Date: Tue, 13 May 2008 00:49:27 GMT
Local: Mon, May 12 2008 8:49 pm
Subject: Re: code written under 5.10.0 to be run under 5.8.8

>>>>> "s" == szr  <sz...@szromanMO.comVE> writes:

  s>    $ perl5.10.0 -e 'print $]'
  s>    5.010000
  s>    $ perl5.8.8 -e 'print $]'
  s>    5.008008
  s>    $ perl5.8.2 -e 'print $]'
  s>    5.008002
  s>    $ perl5.8.0 -e 'print $]'
  s>    5.008
  s>    $ perl5.6.1 -e 'print $]'
  s>    5.006001

  s> Little question: Since this is a floating point number, are there any
  s> rounding-error considerations when making comparisons and such?

those are all well within the float range but i bet they really are
strings. you can check this with some stuff in scalar::util.

  s> Also, is there a reason why 5.10's output pads zeros on the right-hand
  s> end of the number?

that is obvious. there is room for a subrelease number (as in all the
5.8 versions). 5.10.2 will likely have $] as 5.010002

uri

--
Uri Guttman  ------  u...@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 ---------


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
szr  
View profile
 More options May 12, 9:36 pm
Newsgroups: comp.lang.perl.misc
From: "szr" <sz...@szromanMO.comVE>
Date: Mon, 12 May 2008 18:36:32 -0700
Local: Mon, May 12 2008 9:36 pm
Subject: Re: code written under 5.10.0 to be run under 5.8.8

I'll do that.

>  s> Also, is there a reason why 5.10's output pads zeros on the
>  right-hand s> end of the number?

> that is obvious. there is room for a subrelease number (as in all the
> 5.8 versions). 5.10.2 will likely have $] as 5.010002

Well, look at the output I posted; the one for 5.8.0 was 5.0008 (no
right-hand padding) while 5.10.0 is padded. I wanted to know why there
is a discrepancy?

--
szr