Here you are seek()ing $gh (for no good reason, I might add).
Here you are reading from $gh.
Here you are printing to $hh.
There is no place in all of your code where you are writing to $gh.
Because print() by default prints to STDOUT if no other filehandle is
specified.
jue
I went back and tried to use STDOUT as my temp file but couldn't get it
together. This purports again to be a solution:
use strict;
use warnings;
my $filename = 'eph6.txt';
open(my $fh, '<', $filename) or die "cannot open $filename: $!";
my $filename2 = 'temp6.txt';
open(my $gh, '+>', $filename2) or die "cannot open $filename2: $!";
while (my $line = <$fh>) {
$line =~ s/\t/ /g;
$line =~ s/ER/ /g;
$line =~ s/°/ /g;
print STDOUT $line;
print $gh $line;
}
close($fh);
close($gh);
open(my $hh, '<', $filename2) or die "cannot open $filename2: $!";
my $outfile = 'outfile7.txt';
open(my $ih, '>', $outfile) or die "cannot open $outfile: $!";
while (my $line = <$hh>) {
my @s = split /\s+/, $line;
$s[1] =~ s/h//;
$s[2] =~ s/m//;
$s[3] =~ s/s//;
$s[5] =~ s/'//;
for my $i (0..9) {
print STDOUT "s$i is $s[$i]\n";
}
print "@s\n";
print $ih "@s\n";
}
close($hh);
close($ih);
# perl reg12.pl
C:\MinGW\source>type outfile7.txt
Sun 19 43 51 -21 17.8 0.984 -35.020 87.148 Set
Mercury 20 36 41 -16 59.3 0.747 -22.075 84.236 Set
Venus 22 51 18 -7 46.9 0.691 10.142 72.919 Up
Moon 10 24 21 +7 29.5 58.6 -4.992 -102.785 Set
Mars 18 58 51 -23 33.8 2.398 -45.280 90.860 Set
Jupiter 20 17 22 -20 8.1 6.082 -27.618 83.843 Set
Saturn 11 32 29 +5 16.0 8.806 -19.672 -111.729 Set
Uranus 23 23 12 -4 46.5 20.638 18.211 70.235 Up
Neptune 21 41 17 -14 13.9 30.892 -7.527 77.864 Set
Pluto 18 6 40 -17 44.9 32.485 -52.833 108.052 Set
C:\MinGW\source>