Newbie help needed

[email protected] (Alan Cohen) Thu, 10 Apr 2014 09:30:25 -0400
Newsgroups perl.gedcom
Message-ID <CAHzoV5_GYvXC7eAdDm=rVBiBNPm3JgDqkYuU=m2tWubTxJnYBA@mail.gmail.com>
--047d7bf0c1063e3a4e04f6b038aa
Content-Type: text/plain; charset=ISO-8859-1

I am a Gedcom newbie (also an OO newbie) challenged to get a most basic
program using Gedcom.pm to work. Having opened a gedcom file, I can access
a Gedcom::Individual and can retrieve scalar attributes from him. However,
I fail when it comes to using methods that supposedly return an array.
Instead I get things like "Gedcom::Individual=HASH(0x123456789)"

Can someone please tell me where I'm going wrong in (say) the following
example?

#!/bin/perl -w

use warnings;
use strict;

use Gedcom;

my $ged = Gedcom->new(grammar_version => "5.5",
                      gedcom_file     => shift,
                      read_only       => 1);
my $indi="I187";
my $i;
my @array;
my $x;
    $i = $ged->get_individual($indi);
####
# These work...
####
    $x = $i->name;           { print("       name = $x\n"); }
    $x = $i->given_names;    { print("given_names = $x\n"); }
    $x = $i->surname;        { print("    surname = $x\n"); }
    $x = $i->get_value("birth date");{print(" birth date = $x\n"); }
####
# The documentation suggests that many methods return arrays but all of
# them seem to produce "values" such as
#     "Gedcom::Individual=HASH(0x2ab6c30)"
# (I looked at Individual.pm itself and "sub siblings" does seem to be
#  returning an array.
####                    WHAT AM I DOING WRONG!
    @array = $i->siblings();
    for $x (@array)            { print("Sibling $x\n"); }
Sincerely,
  Alan Cohen
  416-783-5383

--047d7bf0c1063e3a4e04f6b038aa
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>I am a Gedcom newbie (also an OO newbie) challenged t=
o get a most basic program using Gedcom.pm to work. Having opened a gedcom =
file, I can access a Gedcom::Individual and can retrieve scalar attributes =
from him. However, I fail when it comes to using<u></u> methods that suppos=
edly return an array. Instead I get things like &quot;Gedcom::Individual=3D=
HASH(0x123456789)&quot;<br>
<br></div>Can someone please tell me where I&#39;m going wrong in (say) the=
 following example?<br><div><div><br><span style=3D"font-family:courier new=
,monospace">#!/bin/perl -w<br><br>use warnings;<br>use strict;<br><br>use G=
edcom;<br>
<br>my $ged =3D Gedcom-&gt;new(grammar_version =3D&gt; &quot;5.5&quot;,<br>=
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 gedcom_file=A0=
=A0=A0=A0 =3D&gt; shift,<br>=A0=A0=A0 =A0=A0=A0 =A0=A0 =A0 =A0 =A0 =A0 =A0=
=A0 read_only=A0=A0=A0=A0=A0=A0 =3D&gt; 1);<br>my $indi=3D&quot;I187&quot;;=
<br>my $i;<br>my @array;<br>
my $x;<br>=A0=A0=A0 $i =3D $ged-&gt;get_individual($indi);<br>####<br># The=
se work...<br>####<br>=A0=A0=A0 $x =3D $i-&gt;name;=A0=A0=A0 =A0=A0=A0 =A0=
=A0 { print(&quot;=A0=A0=A0=A0=A0=A0 name =3D $x\n&quot;); }<br>=A0=A0=A0 $=
x =3D $i-&gt;given_names;=A0=A0=A0 { print(&quot;given_names =3D $x\n&quot;=
); }<br>
=A0=A0=A0 $x =3D $i-&gt;surname;=A0=A0=A0 =A0=A0=A0 { print(&quot;=A0=A0=A0=
 surname =3D $x\n&quot;); }<br>=A0=A0=A0 $x =3D $i-&gt;get_value(&quot;birt=
h date&quot;);{print(&quot; birth date =3D $x\n&quot;); }<br>####<br># The =
documentation suggests that many methods return arrays but all of<br>
# them seem to produce &quot;values&quot; such as<br>#=A0=A0=A0=A0 &quot;Ge=
dcom::Individual=3DHASH(0x2ab6c30)&quot;<br># (I looked at Individual.pm it=
self and &quot;sub siblings&quot; does seem to be<br>#=A0 returning an arra=
y.<br>####=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 WHAT AM I DOING=
 WRONG!<br>
=A0=A0=A0 @array =3D $i-&gt;siblings();<br>=A0=A0=A0 for $x (@array)=A0=A0=
=A0 =A0=A0=A0 =A0=A0=A0 { print(&quot;Sibling $x\n&quot;); }</span><br clea=
r=3D"all"><div>Sincerely,<br>=A0 Alan Cohen<br>=A0 416-783-5383</div>
</div></div></div>

--047d7bf0c1063e3a4e04f6b038aa--