[librecat-dev] my.very.deep.path in Catmandu::Fix::marc_spec
Nicolas Steenlant
Nicolas.Steenlant at UGent.be
Fri Jun 10 14:38:29 CEST 2016
Hi Carsten,
Catmandu::Util has some internal (and undocumented) functions that help with this:
use Catmandu::Util qw(:data);
use Data::Dumper;
my $data = {};
my $nested = data_at('my.very.deep', $data, create => 1, key => 'path');
set_data($nested, 'path', 'a value');
print Dumper($data);
$VAR1 = {'my' => {'very' => {'deep' => {'path' => 'a value'}}}};
Calling data_at without the create => 1 option will not make missing intermediate structures
and return undef in this case.
The key => ‘path’ option gives a hint to data_at that you want ‘deep’ to be a hash
and not an array,
since it can’t guess the type by looking at the next segment of the path.
Regards,
Nicolas
--
Nicolas Steenlant
Ghent University Library
Sint-Hubertusstraat 8
9000 Gent
nicolas.steenlant at ugent.be
+32 486 62 62 27
> On 10 Jun 2016, at 14:05, Klee, Carsten <Carsten.Klee at sbb.spk-berlin.de> wrote:
>
> Hi Catmandu monks!
>
> I’m currently working on the Catmandu::Fix::marc_spec [1]. I chose to stick with a simple ‘fix’ method (emit is quite hairy and Perl is difficult enough to learn).
>
> To make long things short: How do I get my referenced data into the my.very.deep.path?
>
> I read https://librecatproject.wordpress.com/2014/03/26/create-a-fixer-part-2/ . But is there an easy way to reuse the Catmandu::Fix methods in a non emit method?
>
> Cheers!
>
> Carsten
>
>
> [1] <https://github.com/cKlee/Catmandu-Fix-marc_spec>
>
>
> _______________________________________________
> Carsten Klee
> Abt. Überregionale Bibliographische Dienste IIE
> Staatsbibliothek zu Berlin – Preußischer Kulturbesitz
> Potsdamer Straße 33
> 10785 Berlin
>
> Fon: +49 30 266-43 44 02
> Fax: +49 30 266-33 40 01
> carsten.klee at sbb.spk-berlin.de
> www.zeitschriftendatenbank.de
> _______________________________________________
> librecat-dev mailing list
> - send list mails to librecat-dev at lists.uni-bielefeld.de
> - to unsubscribe or change options, visit https://lists.uni-bielefeld.de/mailman2/cgi/unibi/listinfo/librecat-dev
> - project website: http://librecat.org/
More information about the librecat-dev
mailing list