in reply to Re^3: Warnings not working on one machine
in thread Warnings not working on one machine
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Warnings not working on one machine
by questions (Initiate) on Jan 29, 2018 at 15:10 UTC | |
by hippo (Archbishop) on Jan 29, 2018 at 15:50 UTC |