In both cases, warnings and variable contents differ per machine.

Not quite. If you look closely at your outputs, the warnings in test3.pl do not differ between the machines. This is because there are no warnings because the code which would generate them is in test3_utils.pl which does not have warnings enabled.

But not having the warnings enabled is a bad thing because you would miss important points like "Use of implicit split to @_ is deprecated at ./test2.pl line 19." in the older perl. Since you don't see this in the newer perl it's safe to say that it has moved from "deprecated" to "deleted" and hence the code behaves differently. When you first saw that warning in the older perl version you should have taken steps then to code around it and you might not have the problem now in the newer perl version.

Always use warnings and always fix any which are reported.

Update: Here's an example rewrite of test2.pl which produces no warnings and the same output on both v5.10.1 or v5.20.3:

use strict; use warnings; sub ndp { $_ = shift or return 0; /\.(\d*)/ and return length ($1); return 0; } print "decimal places: " . ndp ('1' ) . "\n"; print "decimal places: " . ndp ('0.123') . "\n"; my $line = "apple="; (undef, my $second_part) = split (/=/, $line); my $second_part_components_count = length $second_part ? scalar (my @f +oo = split /;/, $second_part) : 0; print "done\n";

No doubt it could be neater but hopefully it illustrates some approaches for you.


In reply to Re^4: Warnings not working on one machine by hippo
in thread Warnings not working on one machine by questions

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.