When I pass a variable through a couple of subs, it always turns up empty. Why is this ?
sub Main {
my $myVariable = "Test string";
firstSub($myVariable);
}
sub firstSub {
my($myVariable) = @_;
my @array = `some command`;
secondSub(@array, $myVariable);
}
sub secondSub {
my(@array, $myVariable) = @_;
print $myVariable;
}
echo will be undef.
echois no perl function. ALways adduse strict;anduse warnings;to your scripts.@array? Your first code was correctly passing the variables into the function. Now you have confused the issue by adding another problem after your original problem was answered.