Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help accessing array of array references

Status
Not open for further replies.

ssmith001

Programmer
Oct 6, 2005
40
US
I have an array of arrays and here are some of the elements I dumped using Dumper:

$VAR6 = [
'B400',
'A1199P1394',
'A'
];
$VAR7 = [
'B400',
'A1205G2425',
'A'
];
$VAR8 = [
'B400',
'A1205Z1534',
'C'
];
$VAR9 = [
'B400',
'A3280F9366',
'B'

What I am trying to do in the code below is check the 3rd element in the array but I can't seem to figure out how to access this particular one. Can someone help me?

Code:
for my $i ( 0 .. $#item_array ) 
{ 
  my $abc = [ @{$item_array[$i]} ];
	    
  if ( $abc eq 'A' ) 
  {
    LogMsg("   [ @{$item_array[$i]} ]   This is an A item");
  } 
  else 
  {
    LogMsg("   [ @{$item_array[$i]} ]   This is a BCE item");
  }
}
 
Use dereferencing:

Code:
for my $i ( 0 .. $#item_array )
{
  my $abc = [ @{$item_array[$i]} ];
        
  if ( [b]$abc->[2][/b] eq 'A' )
  {
    LogMsg("   [ @{$item_array[$i]} ]   This is an A item");
  }
  else
  {
    LogMsg("   [ @{$item_array[$i]} ]   This is a BCE item");
  }
}
 
Kevin, one last thing...

now I get a bunch of these warnings popping up: Use of uninitialized value in string eq at promo.pl line 420
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top