I'm trying to find if an array's elements are simple strings or if they are hashrefs.

my @a = ('string1','string2','string3');

my @a = (
  { STRING => 'string1', ID => 1 },
  { STRING => 'string2', ID => 2 },
 );

my $aref = [EMAIL PROTECTED]; # this value is passed to a sub

i've tried:

if($aref->[0]->{STRING}){
    print "array contains hash1\n";
}

if(keys %{$aref->[0]}){
    print "array contains hash2\n";
}


but while using strict and testing the plain array, I get an error:
Can't use string ("string1") as a HASH ref while "strict refs" in use


What's the correct method for this?

--

Jeremy Kister
http://jeremy.kister.net./

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to