[32916] in Perl-Users-Digest
Perl-Users Digest, Issue: 4194 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 14 09:09:25 2014
Date: Mon, 14 Apr 2014 06:09:02 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 14 Apr 2014 Volume: 11 Number: 4194
Today's topics:
Crawl nested data structure, apply code block to each <Vorzakir@invalid.invalid>
Re: Crawl nested data structure, apply code block to ea <bjoern@hoehrmann.de>
Re: Crawl nested data structure, apply code block to ea <rweikusat@mobileactivedefense.com>
Re: Crawl nested data structure, apply code block to ea <john@castleamber.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 13 Apr 2014 17:39:14 +0000 (UTC)
From: Randy Westlund <Vorzakir@invalid.invalid>
Subject: Crawl nested data structure, apply code block to each
Message-Id: <liei42$ed4$1@dont-email.me>
I have a simple problem, but am not sure how to solve it. I'm
getting data from a MongoDB database with the MongoDB module. This
returns a BSON (JSON-like) document as a nested data structure with
arbitrary element types. I'm taking that and building a LaTeX
document with the Template::Latex module. This is currently
working, most of the time.
My problem is that the strings I'm pulling from the database
sometimes have an '&' in them, which screws up my tabularx sections
in LaTeX. So I need some way to crawl this data structure and
escape them. I want to do something like call map on all the scalar
values found.
I looked at Data::Nested, but didn't see anything useful for me. Is
there a module that has a function like this, or a concise way to
write this myself?
------------------------------
Date: Sun, 13 Apr 2014 20:01:04 +0200
From: Bjoern Hoehrmann <bjoern@hoehrmann.de>
Subject: Re: Crawl nested data structure, apply code block to each
Message-Id: <sujlk9dj6ode02674a5umios8qfrmf3jii@hive.bjoern.hoehrmann.de>
* Randy Westlund wrote in comp.lang.perl.misc:
>I have a simple problem, but am not sure how to solve it. I'm
>getting data from a MongoDB database with the MongoDB module. This
>returns a BSON (JSON-like) document as a nested data structure with
>arbitrary element types. I'm taking that and building a LaTeX
>document with the Template::Latex module. This is currently
>working, most of the time.
>
>My problem is that the strings I'm pulling from the database
>sometimes have an '&' in them, which screws up my tabularx sections
>in LaTeX. So I need some way to crawl this data structure and
>escape them. I want to do something like call map on all the scalar
>values found.
This sounds like the `&` need to be escaped when the Template::Latex
module combines your template code with the data from the structure.
Ordinarily there should be ways to indicate how values need to be es-
caped (consider generating HTML documents from templates, sometimes
values need to be escaped per HTML rules, sometimes JavaScript rules,
maybe CSS rules, sometimes even a combination of the rules) and I'd
suggest looking for that instead of transforming your data this way.
--
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
------------------------------
Date: Sun, 13 Apr 2014 19:50:23 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Crawl nested data structure, apply code block to each
Message-Id: <877g6tnjww.fsf@sable.mobileactivedefense.com>
Randy Westlund <Vorzakir@invalid.invalid> writes:
> I have a simple problem, but am not sure how to solve it. I'm
> getting data from a MongoDB database with the MongoDB module. This
> returns a BSON (JSON-like) document as a nested data structure with
> arbitrary element types. I'm taking that and building a LaTeX
> document with the Template::Latex module. This is currently
> working, most of the time.
>
> My problem is that the strings I'm pulling from the database
> sometimes have an '&' in them, which screws up my tabularx sections
> in LaTeX. So I need some way to crawl this data structure and
> escape them.
Why don't you escape them on extraction?
------------------------------
Date: Sun, 13 Apr 2014 16:09:39 -0500
From: John Bokma <john@castleamber.com>
Subject: Re: Crawl nested data structure, apply code block to each
Message-Id: <871tx1kkbw.fsf@castleamber.com>
Randy Westlund <Vorzakir@invalid.invalid> writes:
> I have a simple problem, but am not sure how to solve it. I'm
> getting data from a MongoDB database with the MongoDB module. This
> returns a BSON (JSON-like) document as a nested data structure with
> arbitrary element types. I'm taking that and building a LaTeX
> document with the Template::Latex module. This is currently
> working, most of the time.
>
> My problem is that the strings I'm pulling from the database
> sometimes have an '&' in them, which screws up my tabularx sections
> in LaTeX. So I need some way to crawl this data structure and
> escape them. I want to do something like call map on all the scalar
> values found.
Make your own TT filter?
http://template-toolkit.org/docs/modules/Template/Filters.html#section_FILTERS
IIRC you can chain filters, so you can first run your data to your
custom filter, then through the latex filter.
--
John Bokma j3b
Blog: http://johnbokma.com/ Perl Consultancy: http://castleamber.com/
Perl for books: http://johnbokma.com/perl/help-in-exchange-for-books.html
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 4194
***************************************