in reply to recreating an array
Hi :D
After days of messing around with perl mods, trying to get them to work...
It is easier/more important to resolve this issue of installing mods, monk, see Tutorials:A Guide To Installing Modules, installing modules non-interactively, in your home directory
I gave up and am trying to code it myself as it seems simple enough to parse this EXAMPLE DATA
Thats not valid xml, friend /*Mwahaha*
(XML:Simple simply won't work on my host and I don't have access to add other mods) ...
Sir, Yes, even you can use CPAN
I'm looking to create this example from LUA, unless theres an easier way to do this of course
And we should know lua syntax? Boy howdy
Well, it looks close enough to this format, so you can use one of those solutions :D
I'm trying to build an array from the table data above by reading line by line and creating the appropriate array tree
Ok dawg, here you go, magic, Data::Lua - Parse variables out of Lua code.
update: Sorry cat, too much magic, its kinda hard to install, needs Inline::Lua
I'm sure its easy for you all, but not me Thank-you *bow*
Yeah, copy/paste can be easier if you can grok how to use it, see Re^2: parsing XML fragments (xml log files) with... a regex
XML::Simple is easier
#!/usr/bin/perl -- use strict; use warnings; use Data::Dumper; use XML::Simple; my $lua =<<'__LUA__'; <GeocodeResponse> <status>OK</status> <result> <type>street_address</type> <formatted_address>1600 Amphitheatre Pkwy</formatted_address> <address_component> <long_name>1600</long_name> <short_name>1600</short_name> <type>street_number</type> </address_component> </result> </GeocodeResponse> __LUA__ print Dumper( XMLin($lua, ) ), "\n\n"; __END__ $VAR1 = { 'status' => 'OK', 'result' => { 'formatted_address' => '1600 Amphitheatre Pkwy +', 'type' => 'street_address', 'address_component' => { 'short_name' => '1600 +', 'long_name' => '1600' +, 'type' => 'street_num +ber' } } };
Don't feel jealous :D
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: recreating an array
by Inexistence (Acolyte) on Sep 08, 2011 at 21:10 UTC |