[Playlist] problem with perl xspf arrays
Ross Mohn
rpmohn at waxandwane.org
Thu Jun 14 13:27:11 UTC 2007
On Wed, 2007-06-13 at 15:50 -0400, Ross Mohn wrote:
> identifiers don't have any attributes. I'd still like to know a more
> elegant way to GET and SET these array things....
>
> $track->{links}[0][0] = "http://foaf.org/namespace/version1";
> $track->{links}[0][1] = "http://socialnetwork.org/foaf/mary.rdfs";
> print $track->{links}[0][0];
> print $track->{links}[0][1];
>
> $track->{identifiers}[0] = "7e1d6f5f-0ac3-4889-8b57-506a67b459fc";
> print $track->{identifiers}[0];
I worked out a more generalized way to use these elements in the perl
XML::XSPF module so that you don't have to specify the particular array
offsets of each element. Hope it makes sense!
# Here's how to SET these elements:
($track->{identifiers}) = ["7e1d6f5f"];
($track->{links})=[["http://a.org/ns/v1","http://a.org/mary"]];
# Here's how to ADD additional elements:
($track->{identifiers}) = [$track->identifiers, "8e1d6f5f"];
($track->{links})=[$track->links,["http://a.org/ns/v2","http://a.org/john"]];
# Here's the way to access and print these elements:
foreach (@{$track->{identifiers}}) {
print "identifier = $_\n";
}
foreach (@{$track->{links}}) {
print "rel = @{$_}[0]\n";
print "link = @{$_}[1]\n";
}
Thanks for the help! -Ross
More information about the Playlist
mailing list