Convert IRADFLAR output to HTML using Perl

Grater, Larry (
Thu, 30 Oct 1997 16:14:00 -0600

Just a word of introduction.  My name is Larry Grater and I'm a flight
dynamics and control engineer at Lockheed Martin Vought.  Several of us
here at what used to be LTV have subscribed to See-Sat for some time
(mostly ex Scout and ASAT types), but haven't posted much.

I read Craig Cholar's post which describes his KEDIT macro:

<I love Rob Matson's new IRIDFLAR feature that shows the lat/long of
<the best location to see a flare.  I quickly tired, however, of
<entering the coordinates into the Tiger Map Server, so I spent an hour
<or so and wrote an editor macro to convert the IRIDFLAR output file
<an HTML document.  The lat/long coordinates are converted to a
<hyperlink to the Tiger Map Server.  I have a batch file that runs
<and then runs the macro, which produces the HTML file.  I have a
<to the local HTML file, so I'm just a few clicks away from results.

<Since the code is only 78 lines, I hope I don't upset anyone by taking
<the liberty of including it in this post.  Of course, if you don't
<to use the text editor I use (KEDIT, a commercially available program),
<then the macro won't work as-is, but it still might be useful as a
<template for someone to rewrite it using another language.

Greg Speed (one of our simulants) has converted it to Perl script.
Perl for Win32's can be found at  Craig's macro was
a great idea.


Larry D. Grater

$outfile = 'iridium.html';

$file = $ARGV[0];
if (!@ARGV) {
	print "\nEnter input file name: ";
	$file = <STDIN>;
open(FILE,"$file") || die "Could not open $file for read.\n";

#13 97-10-31  5:06:40.0 356 39  5h46  82.8 1143.4 A Lit -20.8  4.69  2.1
 31.9677  -96.3042
@columns = (0,3,11,22,26,29,35,41,48,50,54,60,66,71,80,90);
$url1 = 'HREF=
$url2 =
$url3 = '&act=move&tlevel=-&tvar=-&tmeth=i&mlat=';
$url4 = '&mlon=';
$url5 = '&msym=smalldot&mlabel=&murl=&lat=';
$url6 = '&lon=';
$url7 = '&wid=0.360&ht=0.130&conf=mapnew.con&mlabel=';

open(OUT,">$outfile") || die "Could not open $outfile for write.\n";

print OUT "<html><head><TITLE>Iridium Flares</TITLE><head>
<body bgcolor=white text=black><H1>Iridium Flares</H1>

HEADER: while (<FILE>) {
	if (/^Ir   Date/) {
		@values = split(/\s+/);
		$size = @values;
		print OUT "</pre>\n<table border=1><tr align=center>\n";
		print OUT "    <th>&nbsp\;</th>\n";
		foreach $value (@values) {
			print OUT "    <th>$value</th>\n";
		print OUT "</tr><tr><td colspan=$size></td></tr>\n";
		$junk = <FILE>;
		last HEADER;
	} else {
		print OUT;

BODY: while (<FILE>) {
	if (/^\s+$/) {
		print OUT "<tr><td colspan=$size></td></tr>\n";
		next BODY;
	for ($cnt=0;$cnt<@columns-1;$cnt++) {
		$length = $columns[$cnt+1] - $columns[$cnt];
		$offset = $columns[$cnt];
		$values[$cnt] = substr($_,$offset,$length);
		$values[$cnt] =~ s/^\s*|\s*$//g;
	$date = $values[1];
	($yy,$mo,$dd) = split(/\-/,$date);
	$time = $values[2];
	($hh,$mm,$sec) = split(/\:/,$time);
	($ss,$tenths) = split(/\./,$sec);
	$lat = $values[$#values-1];
	$lon = $values[$#values];
	$percent = '%';
	$mlabel = sprintf("iridium+%02d%3s%02d+%02d%3s%02d%3s%02d",
	$cgi =
	print OUT "<tr align=right><td><b><a $cgi>$counter</a></b></td>\n";
	foreach $value (@values) {
		print OUT "    <td>$value</td>\n";
	print OUT "</tr>\n";
print OUT "</table><P>



# IRIDMAPS v1.0 (Perl version)
#This script was adapted from Craig Cholar's IRIDMAP v1.0 KEDIT macro
# which uses  the output of Rob Matson's IRIDFLAR program.
# The script is written in Perl (download at  The
#output is converted to an HTML document, with the latitude and
#of the flares changed to hyperlinks to the Tiger Map Server (U.S. Only)
#This macro is freeware and is released to the public domain.
#Greg Speed, Larry Grater,, 30 October 1997.