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 "Gedcom::Individual=3D=
HASH(0x123456789)"<br>
<br></div>Can someone please tell me where I'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->new(grammar_version =3D> "5.5",<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> 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> 1);<br>my $indi=3D"I187";=
<br>my $i;<br>my @array;<br>
my $x;<br>=A0=A0=A0 $i =3D $ged->get_individual($indi);<br>####<br># The=
se work...<br>####<br>=A0=A0=A0 $x =3D $i->name;=A0=A0=A0 =A0=A0=A0 =A0=
=A0 { print("=A0=A0=A0=A0=A0=A0 name =3D $x\n"); }<br>=A0=A0=A0 $=
x =3D $i->given_names;=A0=A0=A0 { print("given_names =3D $x\n"=
); }<br>
=A0=A0=A0 $x =3D $i->surname;=A0=A0=A0 =A0=A0=A0 { print("=A0=A0=A0=
surname =3D $x\n"); }<br>=A0=A0=A0 $x =3D $i->get_value("birt=
h date");{print(" birth date =3D $x\n"); }<br>####<br># The =
documentation suggests that many methods return arrays but all of<br>
# them seem to produce "values" such as<br>#=A0=A0=A0=A0 "Ge=
dcom::Individual=3DHASH(0x2ab6c30)"<br># (I looked at Individual.pm it=
self and "sub siblings" 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->siblings();<br>=A0=A0=A0 for $x (@array)=A0=A0=
=A0 =A0=A0=A0 =A0=A0=A0 { print("Sibling $x\n"); }</span><br clea=
r=3D"all"><div>Sincerely,<br>=A0 Alan Cohen<br>=A0 416-783-5383</div>
</div></div></div>
--047d7bf0c1063e3a4e04f6b038aa--