So, here are some examples of code producing different results on both machines. test2.pl runs alone by itself, test3.pl does the exact same tasks but uses the test3_utils.pl file. In both cases, warnings and variable contents differ per machine.
cat test2.pl
#!/usr/bin/perl
use strict;
use warnings;
use Cwd;
use File::Basename;
use List::Util qw(min max);
use Math::Round;
use Sort::Key::Natural qw(natsort);
use Storable 'dclone';
use Sys::Hostname;
use Term::ANSIColor;
print "decimal places: ".length(("1" =~ /\.(\d*)/)[0])."\n";
print "decimal places: ".length(("0.123" =~ /\.(\d*)/)[0])."\n";
my $line = "apple=";
my $second_part = (split(/=/, $line))[1];
my $second_part_components_count = (length $second_part > 0 ? scalar (
+split(/;/, $second_part)) : 0);
print "done\n";
cat test3.pl
#!/usr/bin/perl
use strict;
use warnings;
use Cwd;
use File::Basename;
use List::Util qw(min max);
use Math::Round;
use Sort::Key::Natural qw(natsort);
use Storable 'dclone';
use Sys::Hostname;
use Term::ANSIColor;
require "test3_utils.pl";
do_foo();
do_bar();
print "done\n";
cat test3_utils.pl
#!/usr/bin/perl
sub do_foo
{
print "decimal places: ".length(("1" =~ /\.(\d*)/)[0])."\n";
print "decimal places: ".length(("0.123" =~ /\.(\d*)/)[0])."\n";
}
sub do_bar
{
my $line = "apple=";
my $second_part = (split(/=/, $line))[1];
my $second_part_components_count = (length $second_part > 0 ? scal
+ar (split(/;/, $second_part)) : 0);
}
1; # need to end with a true value
The scripts are copied to the second computer (SciLnx) where they produce different results:
me@UbuntuMachine: ./test2.pl
Use of uninitialized value in concatenation (.) or string at ./test2.p
+l line 14.
decimal places:
decimal places: 3
Use of uninitialized value $second_part in numeric gt (>) at ./test2.p
+l line 19.
done
me@UbuntuMachine: ./test3.pl
decimal places:
decimal places: 3
done
me@SciLnxMachine: ./test2.pl
Use of implicit split to @_ is deprecated at ./test2.pl line 19.
Use of uninitialized value in length at ./test2.pl line 14.
decimal places: 0
decimal places: 3
Use of uninitialized value $second_part in length at ./test2.pl line 1
+9.
done
me@SciLnxMachine: ./test3.pl
decimal places: 0
decimal places: 3
done
I would expect the same results and the same warnings on both machines. To my surprise, neither is the case. The SciLnx is returning 0 where the Ubuntu machine is returning nothing.
The software in question is distributed to partners, it is important that it does what we expect. Is there any way to investigate what is causing this behavioural difference?
|