I've been doing some work on a colleague's script this morning, adding in some (stand-alone) subroutines that I developed as part of the project as a whole.

This, obviously, was trivial enough, and as the subs had previously been tested, I expected the testing of the overall script to be just as trivial. Interestingly, however, I started getting a run-time error message from Perl, that wasn't picked up using perl -c, or during my own testing of the subroutines:

Missing $ on loop variable at Script.pl line 120
Now, line 120 is the start of one of my subroutines, which contains a foreach loop, and very little else (see below for code). The loop variable does, in fact, have a $, and this error seemed bizzare, all the more so because this didn't come up during previous testing.

After some time investigating this, I found that the problem was being caused by the script's shebang line calling a different version of Perl (5.001) to that that I'd done my testing under (5.004.04). If I changed the shebang to call Perl 5.004, the script functioned perfectly happily. Fortunately, running the rest of the script under Perl 5.004 doesn't impact it at all (not that I'd expect it to), and hence we fixed the problem by simply calling the newer version of Perl.

I'm interested to know whether others have experienced problems like this, with multiple versions of Perl being used by the same development team?

If anyone can offer any insights as to why I see the error, at run-time, not at compile-time, I'd be very interested to hear them as well .. :)

sub process_customer_data { my $_cust_data = shift; my %customer_data; foreach my $id (keys %$_cust_data) { # do stuff } return %customer_data; }

-- Foxcub
A friend is someone who can see straight through you, yet still enjoy the view. (Anon)


In reply to Inconsistencies between Perl versions by Tanalis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.