L
Larry Gates
Happy Bye George Day!
I've been chipping away at a long-term project: investigating the
ephemeris. I think it would make a great way to continue exploring perl's
pattern-matching capabilities.
So I'll have a program that looks like this:
my $filename = 'eph3.txt';
open(my $fh, '<', $filename) or die "cannot open $filename: $!";
while (<$fh>) {
print $_;
}
close($fh)
# perl faulk10.pl
or
open(my $fh, '<', 'eph3.txt');
while (my $line = <$fh>) {
print $line;
}
close($fh)
# perl faulk7.pl
I'll want to have an explicit variable for the line, so I'll use the better
parts of the above.
The first thing I'll want to do is capture the first seven characters in a
line. We can assume that these will always be letters or spaces padded out
to the right.
After that, I want to strip away all the characters, as does the following
fortran routine. In this treatment $line would be inrec .
subroutine WasteNonDigits(inrec)
character*80 inrec
character*1 c1,c2
character*13 ValidDigits
data ValidDigits/'0123456789.-+'/
n=13
do i=1,80
c1=' '
c2=inrec(i:i)
do j=1,n
if(c2.eq.ValidDigits(j:j)) c1=c2
end do
inrec(i:i)=c1
end do
return
end subroutine
Ultimately, I want to populate an object that I think would be pretty tame
by perl standards.
This is the data set:
C:\MinGW\source>type eph3.txt
! yesterday
# another comment
Sun 18h 41m 55s -23 5.4' 0.983 10.215 52.155 Up
Mercury 20h 2m 16s -22 12.5' 1.102 22.537 37.668 Up
Venus 21h 55m 33s -14 16.3' 0.795 39.872 11.703 Up
Moon 21h 17m 19s -15 2.4' 62.4 ER 36.796 22.871 Up
Mars 18h 11m 59s -24 6.1' 2.431 4.552 56.184 Up
Jupiter 20h 3m 35s -20 49.4' 6.034 23.867 38.203 Up
Saturn 11h 32m 59s +5 8.6' 9.018 -47.333 157.471 Set
Uranus 23h 21m 30s -4 57.9' 20.421 48.328 -18.527 Up
Neptune 21h 39m 30s -14 22.8' 30.748 38.963 16.599 Up
Pluto 18h 4m 34s -17 44.5' 32.543 7.443 62.142 Up
C:\MinGW\source>
Thanks for your comment.
--
larry gates
You know how people are sometimes rude on Usenet or on a mailing list.
Sometimes they'll write something that can only be taken as a deadly
insult,
and then they have the unmitigated gall to put a smiley face on it, as if
that makes it all right. -- Larry Wall, 8th State of the Onion
I've been chipping away at a long-term project: investigating the
ephemeris. I think it would make a great way to continue exploring perl's
pattern-matching capabilities.
So I'll have a program that looks like this:
my $filename = 'eph3.txt';
open(my $fh, '<', $filename) or die "cannot open $filename: $!";
while (<$fh>) {
print $_;
}
close($fh)
# perl faulk10.pl
or
open(my $fh, '<', 'eph3.txt');
while (my $line = <$fh>) {
print $line;
}
close($fh)
# perl faulk7.pl
I'll want to have an explicit variable for the line, so I'll use the better
parts of the above.
The first thing I'll want to do is capture the first seven characters in a
line. We can assume that these will always be letters or spaces padded out
to the right.
After that, I want to strip away all the characters, as does the following
fortran routine. In this treatment $line would be inrec .
subroutine WasteNonDigits(inrec)
character*80 inrec
character*1 c1,c2
character*13 ValidDigits
data ValidDigits/'0123456789.-+'/
n=13
do i=1,80
c1=' '
c2=inrec(i:i)
do j=1,n
if(c2.eq.ValidDigits(j:j)) c1=c2
end do
inrec(i:i)=c1
end do
return
end subroutine
Ultimately, I want to populate an object that I think would be pretty tame
by perl standards.
This is the data set:
C:\MinGW\source>type eph3.txt
! yesterday
# another comment
Sun 18h 41m 55s -23 5.4' 0.983 10.215 52.155 Up
Mercury 20h 2m 16s -22 12.5' 1.102 22.537 37.668 Up
Venus 21h 55m 33s -14 16.3' 0.795 39.872 11.703 Up
Moon 21h 17m 19s -15 2.4' 62.4 ER 36.796 22.871 Up
Mars 18h 11m 59s -24 6.1' 2.431 4.552 56.184 Up
Jupiter 20h 3m 35s -20 49.4' 6.034 23.867 38.203 Up
Saturn 11h 32m 59s +5 8.6' 9.018 -47.333 157.471 Set
Uranus 23h 21m 30s -4 57.9' 20.421 48.328 -18.527 Up
Neptune 21h 39m 30s -14 22.8' 30.748 38.963 16.599 Up
Pluto 18h 4m 34s -17 44.5' 32.543 7.443 62.142 Up
C:\MinGW\source>
Thanks for your comment.
--
larry gates
You know how people are sometimes rude on Usenet or on a mailing list.
Sometimes they'll write something that can only be taken as a deadly
insult,
and then they have the unmitigated gall to put a smiley face on it, as if
that makes it all right. -- Larry Wall, 8th State of the Onion