Find the answer to your Linux question:
Results 1 to 3 of 3
I am sitting here at my computer at 2:30am on a saturday morning with no idea what the hell im doing. But here's my goal I have a KML File ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2010
    Posts
    1

    Post Help a guy learn some perl


    I am sitting here at my computer at 2:30am on a saturday morning with no idea what the hell im doing. But here's my goal

    I have a KML File for Google Earth. This file is generated with the GPS locations of certain sites.

    I have a text file with extra information about certain sites. What i'm trying to figure out how to do is by using perl I want to open the text file grab the first location on line one and search for it in the KML file. When that line is found I want to edit the Description field in that KML file and add something to the description and change the placemark from Yellow to Blue.

    Can anyone give me advice on the best way to handle this and where I can start. I can understand if nobody wants to give me the answer directly but I would like to be pointed in the right direction I would greatly appreciate it.

  2. #2
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    Do you know Perl already? I will assume that you know how to open a file and read the first location on its line.

    Now then, I don't know what KML is, but as a general rule it is very difficult to modify a file in-place. It basically requires that your new values are the exact same length as whatever they're overwriting, and it's generally a bad idea. So what you're probably going to want to do is read the KML file into memory (parsing it as necessary), and then read your text file, get the location, and modify that in-memory KML file. Once you've done all of your modifications, you can print the file out.

    Does this make sense?

  3. #3
    Linux Newbie
    Join Date
    Apr 2010
    Location
    Novosibirsk, Russia
    Posts
    145

    Post

    Quote Originally Posted by Shadowbug View Post
    I am sitting here at my computer at 2:30am on a saturday morning with no idea what the hell im doing. But here's my goal

    I have a KML File for Google Earth. This file is generated with the GPS locations of certain sites.

    I have a text file with extra information about certain sites. What i'm trying to figure out how to do is by using perl I want to open the text file grab the first location on line one and search for it in the KML file. When that line is found I want to edit the Description field in that KML file and add something to the description and change the placemark from Yellow to Blue.

    Can anyone give me advice on the best way to handle this and where I can start. I can understand if nobody wants to give me the answer directly but I would like to be pointed in the right direction I would greatly appreciate it.
    I suppose you should read about regular expressions to perform this task.
    Code:
    perldoc perlre
    will ultimately helps you

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •