Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to split this array in perl?

Tags:

arrays

perl

How to split the following array so that i can get lon and lat points only every time ? In perl Script ?

[{"lon":77.594376,"lat":12.971606,"bfg":18000,"xyz":null,"jky":null},{"lon":77.604376,"lat":12.980606,"bfg":18000,"xyz":null,"jky":null},{"lon":77.674376,"lat":12.981606,"bfg":18000,"xyz":null,"jky":null},{"lon":77.684376,"lat":12.982606,"bfg":18000,"xyz":null,"jky":null},{"lon":77.744376,"lat":12.983606,"bfg":18000,"xyz":null,"jky":null},{"lon":77.784376,"lat":12.990606,"bfg":18000,"xyz":null,"jky":null},{"lon":77.804376,"lat":12.991606,"bfg":18000,"xyz":null,"jky":null},{"lon":77.824376,"lat":12.995606,"bfg":18000,"xyz":null,"jky":null},{"lon":77.874376,"lat":12.997606,"bfg":18000,"xyz":null,"jky":null},{"lon":77.894376,"lat":12.999606,"bfg":18000,"xyz":null,"jky":null}]

Any help ?

like image 425
SSS Avatar asked Sep 10 '12 08:09

SSS


1 Answers

You can use a JSON library in Perl to parse your JSON string. After that, you will have an array of hashes that you can iterate over and extract the lat/lon values.

like image 188
j0nes Avatar answered Nov 03 '22 00:11

j0nes