Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

How to Run/Convert(?) Script Built on 5.8.4 to 5.004

by neversaint (Deacon)
on May 08, 2007 at 14:51 UTC ( #614157=perlquestion: print w/ replies, xml ) Need Help??
neversaint has asked for the wisdom of the Perl Monks concerning the following question:

Dear Masters,
I have several Perl scripts which was written under Perl version 5.8.4. Now I need to run them on a office server where Perl 5.004 was installed. (And I have no option to install Perl interpreter on my home directory).

Is there a way I can quickly convert/run my code such that it can be executed on environment where Perl 5.004 is installed?

---
neversaint and everlastingly indebted.......

Comment on How to Run/Convert(?) Script Built on 5.8.4 to 5.004
Re: How to Run/Convert(?) Script Built on 5.8.4 to 5.004
by jettero (Monsignor) on May 08, 2007 at 15:08 UTC

    It really depends on the code. There's no automatic way if that's what you mean.

    Most things should run just fine. Some 5.8.x standard modules will be missing but will be available on CPAN. Others will be problematic to say the least. Cool syntaxes like open my $in, "<", $filename will likely have to be uncoolized... And now I'm rambling. But you see what I mean.

    -Paul

      Some 5.8.x standard modules will be missing but will be available on CPAN

      If that "some" includes; Encode, utf8 and friends, they can not be installed on legacy perl. Anything unicode related will not work or will not be correct.

      Also there is an "our()" issue. If this is used, all must be replaced with "use vars"...

Re: How to Run/Convert(?) Script Built on 5.8.4 to 5.004
by swampyankee (Parson) on May 08, 2007 at 15:47 UTC

    Well, the first thing I'd try (as part of my Brute Force & Ignorance™ testing style) is to see which of your scripts work on the office server without change. You may luck out and have no work to do or find that the work is trivial.

    If that doesn't work and you think changing the scripts is too much work, you could try convincing the sysadmin who manages your office server to install Perl 5.8 (recommended course).

    emc

    Insisting on perfect safety is for people who don't have the balls to live in the real world.

    —Mary Shafer, NASA Dryden Flight Research Center
Re: How to Run/Convert(?) Script Built on 5.8.4 to 5.004
by Albannach (Prior) on May 08, 2007 at 16:04 UTC
    You might try using pp to package your scripts on your development machine with your development version of Perl, and they should run with your development version on the other machine, albeit with much slower startup times. pp can be fussy at times, but if your scripts aren't too odd this could be a very easy solution.

    Note: I use pp often for target machines with no Perl installed at all, and I believe but am not certain that this approach will leave the old 5.004 installation unharmed (and hopefully the permissions are correctly set to ensure this) but I can't guarantee it.

    --
    I'd like to be able to assign to an luser

Re: How to Run/Convert(?) Script Built on 5.8.4 to 5.004
by grinder (Bishop) on May 08, 2007 at 16:28 UTC
    I need to run them on a office server where Perl 5.004 was installed

    You might be interested in a talk Sébastien Aperghis-Tramoni gave at the Nordic Perl Workshop 2007 entitled Old Perls and New Code. It sounds like it covers the problem you're facing.

    • another intruder with the mooring in the heart of the Perl

Re: How to Run/Convert(?) Script Built on 5.8.4 to 5.004
by Limbic~Region (Chancellor) on May 08, 2007 at 17:07 UTC
    neversaint,
    This sounds like it might be a great (ab)?use of a Code::Critic policy. I do not know of any conversion routines and, quite frankly, I wouldn't trust them if they did exist.

    Simply correcting issues identified by perl -Mstrict -wc script.pl is not going to cut the mustard but it is probably a good start. The problem arises when the code is valid (it compiles) but does not behave the same. That is why you should have a test-suite that works with the oldest version of Perl you intend to support.

    Cheers - L~R

Re: How to Run/Convert(?) Script Built on 5.8.4 to 5.004
by NiJo (Friar) on May 08, 2007 at 17:45 UTC
    Perlcc creates and compiles C code from your script. My suggestion is to compile in the 5.8.4 environment and deploy on (but don't use) 5.004. If you are using the same platform and if it is an standaolen type of script it might be feasible. But this is an experimental feature that requires full testing.

      Unfortunately, perlcc doesn't work, and likely won't ever work. No one works on it.

Re: How to Run/Convert(?) Script Built on 5.8.4 to 5.004
by Burak (Chaplain) on May 08, 2007 at 19:14 UTC
Re: How to Run/Convert(?) Script Built on 5.8.4 to 5.004
by ddn123456 (Pilgrim) on May 09, 2007 at 07:53 UTC
    Alternatively as a quick workaround you could compile them into executables with the perl development kit.

    Or even put them into 1 structured script either OO or procedural) with the possibility to launch the required internal functions & subprocedures by passing on specific commandline parameters. Then you can compile this into 1 general executable with the perl development kit.

    Like this all required perl binaries and script code are compiled and the dependency on a perl platform is skipped for production environment.

    The pdk only takes the minimum it needs to create the executable so you may end up with a file far smaller than the size of your perl installation.

    In development environment however you will still need it.

    Regards.

    ddn123456
Re: How to Run/Convert(?) Script Built on 5.8.4 to 5.004
by Moron (Curate) on May 09, 2007 at 15:09 UTC
    perl -c works under 5.004 I think - identify each type of error with this and make a manual change e.g.
    open my $fh, "<file.txt" or die "blah $!\n";
    produces with perl -c (can run perl -c on anything including .pm files)
    Can't use an undefined value as filehandle reference at blah.pl line 1 +23
    So you resolve it with...
    use FileHandle # ... my $fh = new FileHandle(); $fh -> open( "< file.txt" ) or die "blah $!\n";
    It shouldn't take too long -- if there are too many, write a converter that implicitly splits by assigning $/ = ';', pattern-matches for each issue and does the conversion - it's not much work actually.

    You'll also have to read release notes of intervening versions.

    __________________________________________________________________________________

    ^M Free your mind!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://614157]
Approved by varian
Front-paged by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (11)
As of 2014-07-23 12:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (140 votes), past polls