Well, let's do what we should do when we have a data structure we don't understand: look at it in the debugger.
$ perl -d xml_sample.pl
Loading DB routines from perl5db.pl version 1.28
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(xml_sample.pl:5): my $config = XMLin("testFile.xml",forc
+earray => ['person','email']);
+ DB<1> l
5==> my $config = XMLin("testFile.xml",forcearray => ['person','ema
+il']);
6: my @persons = $config->{person};
7: print "Size:".@persons;
DB<1> c 6 # run continuously to line 6
main::(xml_sample.pl:6): my @persons = $config->{person};
DB<2> x $config
0 HASH(0x1988e88)
'person' => ARRAY(0x19acb00)
0 HASH(0x1988f30)
'email' => ARRAY(0x19acba8)
0 'joe@smith.com'
1 'jsmith@yahoo.com'
'firstname' => 'Joe'
'lastname' => 'Smith'
1 HASH(0x198a0cc)
'email' => ARRAY(0x19acab8)
0 'bob@smith.com'
'firstname' => 'Bob'
'lastname' => 'Smith'
DB<3> q
$
So we can see that the value of
$config->{person} is actually a
reference to an array, not an array itself. You'll have to
dereference it to get an actual array. Try
@{ $config->{person} }. The elements in the array created by this expression will be the two references to the hashes containing references to arrays containing the email values.