loosecannon1
Programmer
Ok this one's really got me twisted up. I'm trying to set the value of a hash to another hash if two values are the same.
It works with the following for loop:
for(@{$IOprocedures{all}{active}}) {
if ($IOprocedures{current}{number} eq $_->{number}) {
$IOprocedures{current}{active} = $_;
print "[$IOprocedures{current}{active}{number}]\n";
}
}
But not with using the grep function. WHY? WHY? WHY? I receive an error: "Can't use string ("1"
as a HASH ref while "strict refs" in use at generateIO.pl line 164." when using the following code:
$IOprocedures{current}{active} =
grep { $IOprocedures{current}{number} eq $_->{number} }
@{$IOprocedures{all}{active}};
print "[$IOprocedures{current}{active}{number}]\n";
My deadline is fast approaching so I'll use for loop, for now. I'm really at a loss on this.
It works with the following for loop:
for(@{$IOprocedures{all}{active}}) {
if ($IOprocedures{current}{number} eq $_->{number}) {
$IOprocedures{current}{active} = $_;
print "[$IOprocedures{current}{active}{number}]\n";
}
}
But not with using the grep function. WHY? WHY? WHY? I receive an error: "Can't use string ("1"
$IOprocedures{current}{active} =
grep { $IOprocedures{current}{number} eq $_->{number} }
@{$IOprocedures{all}{active}};
print "[$IOprocedures{current}{active}{number}]\n";
My deadline is fast approaching so I'll use for loop, for now. I'm really at a loss on this.