in reply to Re: Another scoping issue: How do I send 2 variables to my sub and use both.
in thread Another scoping issue: How do I send 2 variables to my sub and use both.

I have tried it both ways and I am getting a message about "use of uninitialized value in concat......"

sub getPlatformFiles { # my ($plat_in, $nic_in) = @_; my $plat_in = shift; my $nic_in = shift; my @list; print "<$plat_in>\n"; #debugging print "<$nic_in>\n"; #debugging if ($plat_in =~ /RedHat/) { @list = ("/etc-test/resolv.conf", "/etc-test/sysconfig/network-scripts/ifcfg-$nic->{de +vice}"); } return @list; }

The first debugging has the correct value but the second is blank empty. It prints <>

Replies are listed 'Best First'.
Re^3: Another scoping issue: How do I send 2 variables to my sub and use both.
by kennethk (Abbot) on Feb 05, 2010 at 17:56 UTC
    "/etc-test/sysconfig/network-scripts/ifcfg-$nic->{device}");

    should read

    "/etc-test/sysconfig/network-scripts/ifcfg-$nic_in->{device}");

    - you missed a search and replace. If you are using strict and it did not get caught, that would be for the reason I detailed before.

    If print "<$nic_in>\n"; is not outputting something that looks like <HASH(0x236e88)>, then you are passing it an undefined value. Are you calling the subroutine with something that looks like getPlatformFiles($platform,$nic);? Are you sure $nic is defined?