-5

I would like a batch that reads a file called ships.txt, then takes the entries (each on a line) from that file and compares them to a file with the file extension of *.map (say test.map), looking for the match, which will always be at the end of a line. Then take those coordinates (they will be a pair of numbers that are actually long. and lat. in meters) and plug those coordinates into a perl script, which produces a file. I'd like then to read the file that is produced by the perl script and delete an entry that is found within another file using information from the perl script by-product.

Lets start from scratch. One step at a time Step 1:

  1. I would like a batch that compares "test.map" and "ships.txt". If it finds a match, and the match will always be at the end of a line in test.map, I'd like it to grab map coordinates.

This is what test.map will look like:

Code:

 Pt0=14497903.00,-813490.00,0.00,Mark 1
 Pt1=14417253.00,-812258.00,0.00,Mark 2
 etc...

ships.txt will look something like this:

 Mark 1
 Mark 3
 etc...

So I'd like the batch to read ships.txt and be looking for the entry "Mark 1" or "Mark 2" etc..., and if it is found in test.map, to grab the coordinates just before the ",0.00,Mark #" Notice the coordinates have two decimal places and they can also be negative.

How is this done?

Jason
  • 1
  • 1

1 Answers1

3

Here is how it could be done.

Here is how you could open a file for read or write in perl. Then you have to read the files, line by line. Maybe it is better to use text::csv to read the files.

Use split or text::csv to create array from the first file lines, and store it in a hash, key should the last field of that file.

When you iterate over the second file, you could use this hash to check it in the first file or not.

Then write your result to a file.

Try to write your code and if you have a specific question you could create a new one.

Or you could hire someone to do this for you.

Regards

user1126070
  • 5,059
  • 1
  • 16
  • 15