List Info

Thread: Hash assignment keys




Hash assignment keys
country flaguser name
United States
2007-09-10 13:40:25


I'm dong a for loop and using the number count to assign as part of the
hash key. The test print inside the sub program work fine, but outside
the program it comes up uninitialized. I think the $i is being used as
part of the key name and not the value of $i which is what I want.
HELP!

&get_assign(%refHas, $zone_dir, $lic)
print "TEST $refHas->{$lic}->{ass_port1}n";
print "TEST $refHas->{$lic}->{ass_port1}n";

sub get_assign{
my ($refHas, $zone_dir, $lic) = _;
for ($x = 0, my $i = 0 ; $x <= $#gline; $x++, $i++) {
if ($x == 0) {
$refHas-&gt;{$lic}-&gt;{ass_master} = $lic_dat[1];
$refHas-&gt;{$lic}-&gt;{ass_master_port} = $lic_dat[3];
} else {
$refHas-&gt;{$lic}-&gt;{ass_slave.Si} = $lic_dat[1];
$refHas-&gt;{$lic}-&gt;{ass_port.$i} = $lic_dat[3];
print "TEST $refHas-&gt;{$lic}-&gt;{ass_port.$i}n&quot;;
print "TEST $refHas-&gt;{$lic}-&gt;{ass_port.$i}n&quot;;
}
}

-----
Don Dukelow
HP License Management Team
Hewlett-Packard Company
Cell: 1-810-728-3388
e-mail: dukelow%40hp.com">dukelowhp.com
URL: http://www.hp.ca

__._,_.___
.

__,_._,___
RE: Hash assignment keys
country flaguser name
United States
2007-09-10 13:58:51

Disregard I found it, I had a hidden character in my assignment line.
I've found that vi does that when you have fat fingers.


-----
Don Dukelow
HP UNIX OVO Enrollment
Hewlett-Packard (Canada) Co.
e-mail: dukelow%40hp.com">dukelowhp.com
URL: http://www.hp.ca <http://www.hp.ca/&gt;

________________________________

From: perl-beginner%40yahoogroups.com">perl-beginneryahoogroups.com
[mailto: perl-beginner%40yahoogroups.com">perl-beginneryahoogroups.com] On Behalf Of Dukelow, Don
Sent: Monday, September 10, 2007 2:40 PM
To: perl-beginner%40yahoogroups.com">perl-beginneryahoogroups.com
Subject: [PBML] Hash assignment keys

I'm dong a for loop and using the number count to assign as part of the
hash key. The test print inside the sub program work fine, but outside
the program it comes up uninitialized. I think the $i is being used as
part of the key name and not the value of $i which is what I want.
HELP!

&amp;get_assign(%refHas, $zone_dir, $lic)
print "TEST $refHas-&gt;{$lic}-&gt;{ass_port1}n";
print "TEST $refHas-&gt;{$lic}-&gt;{ass_port1}n";

sub get_assign{
my ($refHas, $zone_dir, $lic) = _;
for ($x = 0, my $i = 0 ; $x <= $#gline; $x++, $i++) {
if ($x == 0) {
$refHas->{$lic}->{ass_master} = $lic_dat[1];
$refHas->{$lic}->{ass_master_port} = $lic_dat[3];
} else {
$refHas->{$lic}->{ass_slave.Si} = $lic_dat[1];
$refHas->{$lic}->{ass_port.$i} = $lic_dat[3];
print "TEST $refHas-&gt;{$lic}-&gt;{ass_port.$i}n&quot;;
print "TEST $refHas-&gt;{$lic}-&gt;{ass_port.$i}n&quot;;
}
}

-----
Don Dukelow
HP License Management Team
Hewlett-Packard Company
Cell: 1-810-728-3388
e-mail: dukelow%40hp.com">dukelowhp.com <mailto:dukelow%40hp.com>
URL: http://www.hp.ca <http://www.hp.ca>;

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )