EPrints Technical Mailing List Archive

Message: #00840


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

[EP-tech] Re: Random question: Eprint core fields


Il 04/07/2012 17:19, Sebastien Francois ha scritto:
Yuri,

This will work:

print $eprint->get_value( 'creators' )->[0];

Or:

print $eprint->get_value( 'creators' )->[0]->{name}->{given};

(but that's not very pretty! :-))

->[0] is orrible and unthinkable :-)


Perhaps you're confusing array and array refs:

my @array = ( 'hello', 'world' );
my $arrayref = [ 'hello', 'world' ];

I thought they was the same! :-o


# both prints 'hello':
print $array[0];
print $arrayref->[0];

Thanks for the precious info! I've still a lot to learn about perl.

I love python but perl can still do a lot :-P


Seb.

On 04/07/12 16:12, Yuri wrote:
I agree. I  perl you can have an array, but [0] return error. If you
cicle on it, you get the results.

You can try it with $eprint->get_value( 'creators' )[0]<- does not work

returning $eprint->get_value( 'creators' ) gives an ARRAY *hex number*

foreach my $c ( @{$creators} )

works.

I don't know why :-)
*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/