in reply to RegEx Riddle

What about some good old plain logic?

What I read is that you want to associate the very next occurrence of coordinates, and the next occurrence only, with the last occurring name. Then:

$coords_found_flag = 0; open(KMLFILE, $kml_file) or die("cannot open file : $kml_file $! "); while ($line = <KMLFILE>) { if ($line =~ m/<name>(.*)<\/name>/) { $current_name = $1; $coords_found_flag = 0; } elsif ($line =~ m/<coordinates>(.*)<\/coordinates>/ && $coords_fou +nd_flag == 0) { $coords{$current_name} = $1; $coords_found_flag = 1; } } close(KMLFILE);



Forget that fear of gravity,
Get a little savagery in your life.