Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

this is probably very simple but I can't get it to work - I can't get any array values from this code using IPTC:
use Image::IPTCInfo; my $info = new Image::IPTCInfo("../testimage.jpg"); my @keywordsRef = $info->Keywords(); foreach $keywordsRef (@keywordsRef) { print "$keywordsRef\n"; }
the result I get is:
ARRAY(0x817872c)

Replies are listed 'Best First'.
Re: cannot get array values
by jeffa (Bishop) on Dec 29, 2003 at 17:08 UTC
    Looks like Keywords() returns an array reference, not an array. Try this:
    my $keywords = $info->Keywords; foreach my $keyword (@$keywords) { print "$keyword\n"; } # or more succintly as print "$_\n" for @$keywords;

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
Re: cannot get array values
by Roy Johnson (Monsignor) on Dec 29, 2003 at 17:09 UTC
    Refs are scalars, not arrays. Try:
    my $keywordsRef = $info->Keywords(); foreach $k (@$keywordsRef) { ...

    The PerlMonk tr/// Advocate