Re: loop

"[email protected] [sed-users]" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>


 # cat lg.plx
 url='https://maps.googleapis.com/maps/api/geocode/json?address='
 

 CSV='input.csv'
 

 perl -Mvars='$URL,@F' -wMstrict -sple '
    @F = split /;/, $_, 8; # ensure line has exactly eight fields
 

    # Index 
    #     0                 1                2         3        4                5          6  7
   # firstname;lastname;adress;town;country;Goog_add;lt;lg

 

    # skip non-interesting lines
    next if "@F[2..4]" =~ /^\s+$/ or "@F[5..7]" =~ /\S/;
 

    y/ /+/ for my $i = join "", @F[2..4];
 

    chomp(my @curl = qx{curl -s "$URL/$i"});
 

    my $content = do{reset;
       join(";",
          map {
             ($_) = /[:]\s+(.+?)[,]?\s*$/;
             /"(.*)"/ ? $1 : $_
          }
          grep {
             m?lat? or m?lng? or m?formatted_address?
          }
          @curl
       )};
       
    $_ = join(  ";",  @F[0..4],    "\e[31m$content\e[0m"   );

 

 '     --        -URL="$url"         "$CSV"
 

 

 HTH
 -Rakesh
 




[Non-text portions of this message have been removed]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.