EPrints Technical Mailing List Archive
Message: #00842
< 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
- To: eprints-tech@ecs.soton.ac.uk
- Subject: [EP-tech] Re: Random question: Eprint core fields
- From: Ian Stuart <Ian.Stuart@ed.ac.uk>
- Date: Thu, 05 Jul 2012 10:03:34 +0100
On 05/07/12 08:16, Yuri wrote:
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 :-)
Not at all.... references are a thing of beauty and power!"print $eprint->get_value( 'creators' )->[0]->{name}->{given};" breaks down very sensibly:
1) use the "get_value" method on the $eprint object, to get the value held in "creators". We are told in the documentation (stop laughing at the back) that this is a reference to an array. 2) From the reference, get element Zero. We are told in the documentation (stop laughing at the back) that this is a reference to an associative array. 3) From this reference, get 'name' element. We are told in the documentation (stop laughing at the back) that this is a reference to an associative array. 4) From this reference, get 'given' element. We are told in the documentation (stop laughing at the back) that this is a scalar value, a "string".
5) Print the string.Not to blow my own trumpet or anything, but have a look at http://devel.edina.ac.uk:1201/cgi/api5?format=text&org=4407 for an example of a fairly complex perl nested data-object.
Anything in {} is a hash, anything in [] is a list. 'dec_lower' => '147.64.0.0' is a simple hash element'identities' => [{},{}] is a hash element who's value is a reference to an anonymous array, each of who's elements are (in turn) references to an anonymous hash (and I'm not showing data in the hashes)
-- Ian Stuart. Developer: ORI, RJ-Broker, and OpenDepot.org Bibliographics and Multimedia Service Delivery team, EDINA, The University of Edinburgh. http://edina.ac.uk/ This email was sent via the University of Edinburgh. The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.
- References:
- [EP-tech] Random question: Eprint core fields
- From: John Salter <J.Salter@leeds.ac.uk>
- [EP-tech] Re: Random question: Eprint core fields
- From: Ian Stuart <Ian.Stuart@ed.ac.uk>
- [EP-tech] Re: Random question: Eprint core fields
- From: Sebastien Francois <sf2@ecs.soton.ac.uk>
- [EP-tech] Re: Random question: Eprint core fields
- From: John Salter <J.Salter@leeds.ac.uk>
- [EP-tech] Re: Random question: Eprint core fields
- From: Yuri <yurj@alfa.it>
- [EP-tech] Re: Random question: Eprint core fields
- From: Sebastien Francois <sf2@ecs.soton.ac.uk>
- [EP-tech] Re: Random question: Eprint core fields
- From: Yuri <yurj@alfa.it>
- [EP-tech] Random question: Eprint core fields
- Prev by Date: [EP-tech] Re: Random question: Eprint core fields
- Next by Date: [EP-tech] Installaton error, screen shot attached.
- Previous by thread: [EP-tech] Re: Random question: Eprint core fields
- Next by thread: [EP-tech] Re: Random question: Eprint core fields
- Index(es):