inputting the ephemerides

C

Charlton Wilbur

LG> How does a person know what the appropriate whence value is?

perldoc -f seek

Didn't you read it the first time you were pointed at it?

Charlton
 
L

Larry Gates

LG> How does a person know what the appropriate whence value is?

perldoc -f seek

Didn't you read it the first time you were pointed at it?

Charlton

I read that and a similar treatment in the camel book.

Now that I've read it for a third time, I think I get it. So
seek($fh,0,SEEK_SET);
is another way to start at the zeroeth byte. (?)
--
larry gates

People who understand context would be steamed to have someone else
dictating how they can call it.
-- Larry Wall in <[email protected]>
 
L

Larry Gates

Larry Gates said:
How would you get rid of the ° and the ' and leave the -44.6 in the
following:
° -44.6'

On way:
my $s = substr('° -44.6\'', 1, length($t)-2);

Another way
my @s = split(//,'° -44.6\'');
my $s = join('', @s[1..$#s-1]);


Or you could play the old
chop
reverse
chop
reverse
trick.

I'm sure there are many more ways to remove the first and last character
of a string.

jue

Thanks jü. Now that we're a little farther down the road, I've found
another way to deal with ° /t and ER, which were the troublemakers for
these data:

my $filename = 'eph6.txt';
my $filename2 = 'outfile1.txt';
open(my $fh, '<', $filename) or die "cannot open $filename: $!";
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 $gh $line;
print STDOUT $line;
}
close($fh);

# seek($fh,0,0);

close($gh);

# perl reg1.pl


C:\MinGW\source>perl reg1.pl
Sun 19h 43m 51s -21 17.8' 0.984 -35.020 87.148 Set
Mercury 20h 36m 41s -16 59.3' 0.747 -22.075 84.236 Set
Venus 22h 51m 18s -7 46.9' 0.691 10.142 72.919 Up
Moon 10h 24m 21s +7 29.5' 58.6 -4.992 -102.785 Set
Mars 18h 58m 51s -23 33.8' 2.398 -45.280 90.860 Set
Jupiter 20h 17m 22s -20 8.1' 6.082 -27.618 83.843 Set
Saturn 11h 32m 29s +5 16.0' 8.806 -19.672 -111.729 Set
Uranus 23h 23m 12s -4 46.5' 20.638 18.211 70.235 Up
Neptune 21h 41m 17s -14 13.9' 30.892 -7.527 77.864 Set
Pluto 18h 6m 40s -17 44.9' 32.485 -52.833 108.052 Set
C:\MinGW\source>

Now, all the terms are delimited by / /; the characters are all ascii; the
ER after the moon is gone, so there is the same number of terms per line.

Wouldn't a split work well here?
--
larry gates

/* This bit of chicanery makes a unary function followed by
a parenthesis into a function with one argument, highest precedence. */
-- Larry Wall in toke.c from the perl source code
 
L

Larry Gates

You can use m// in a list context to get all the captures:

my @matches = / big ol' honkin' regex /;
print "$_ ==> '$matches[$_]'\n" for 0 .. $#matches;

I'm not following.
q1) Why do you have a backslash after °, h, and m, but not s and ' ?


It is not a backslash after "h". It is a backslash before a space character.

Since you're using m//x, space characters are normally ignored. If you
do not want them to be treated normally (ignored) then you must
escape them.

I personally never use /h\ /.

I would instead use either /h[ ]/ or maybe /h\s/.

(Not really. I would really use either /h [ ]/x or /h \s/x :)

With /x, it's different than the s/// because spaces are significant there.
A "pattern" (my favorite) or a "regular expression" or a "regex".

Seems rather obvious now.
--
larry gates

: I could understand principles of Perl source in 2-3 days [. . .]

Gee, it took me about eleven years. :)
-- Larry Wall in <[email protected]>
 
T

Tim Greer

Larry said:
Larry Gates said:
How would you get rid of the ° and the ' and leave the -44.6 in the
following:
° -44.6'

On way:
my $s = substr('° -44.6\'', 1, length($t)-2);

Another way
my @s = split(//,'° -44.6\'');
my $s = join('', @s[1..$#s-1]);


Or you could play the old
chop
reverse
chop
reverse
trick.

I'm sure there are many more ways to remove the first and last
character of a string.

jue

Thanks jü. Now that we're a little farther down the road, I've found
another way to deal with ° /t and ER, which were the troublemakers for
these data:

my $filename = 'eph6.txt';
my $filename2 = 'outfile1.txt';
open(my $fh, '<', $filename) or die "cannot open $filename: $!";
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 $gh $line;
print STDOUT $line;
}
close($fh);

# seek($fh,0,0);

close($gh);

# perl reg1.pl


C:\MinGW\source>perl reg1.pl
Sun 19h 43m 51s -21 17.8' 0.984 -35.020 87.148 Set
Mercury 20h 36m 41s -16 59.3' 0.747 -22.075 84.236 Set
Venus 22h 51m 18s -7 46.9' 0.691 10.142 72.919 Up
Moon 10h 24m 21s +7 29.5' 58.6 -4.992 -102.785 Set
Mars 18h 58m 51s -23 33.8' 2.398 -45.280 90.860 Set
Jupiter 20h 17m 22s -20 8.1' 6.082 -27.618 83.843 Set
Saturn 11h 32m 29s +5 16.0' 8.806 -19.672 -111.729 Set
Uranus 23h 23m 12s -4 46.5' 20.638 18.211 70.235 Up
Neptune 21h 41m 17s -14 13.9' 30.892 -7.527 77.864 Set
Pluto 18h 6m 40s -17 44.9' 32.485 -52.833 108.052 Set
C:\MinGW\source>

Now, all the terms are delimited by / /; the characters are all ascii;
the ER after the moon is gone, so there is the same number of terms
per line.

Wouldn't a split work well here?

Split works well when you don't have white space in the fields
themselves, and the fields don't change within the range you want to
grab them from.
 
T

Tad J McClellan

.... and never need to use explicit $1, $2, etc.

my @matches = / big ol' honkin' regex /;
print "$_ ==> '$matches[$_]'\n" for 0 .. $#matches;

I'm not following.


---------------------------------
#!/usr/bin/perl
use warnings;
use strict;

$_ = 'Sun 19h 43m 51s';

my @matches = /(\w+)\s+(\d+h)\s(\d+m)\s(\d+s)/;
print "$_ ==> '$matches[$_]'\n" for 0 .. $#matches;

# OR even:

my($body, $hour, $minute, $second) = /(\w+)\s+(\d+h)\s(\d+m)\s(\d+s)/;
print "body: $body\n";
print "hour: $hour\n";
print "minute: $minute\n";
print "second: $second\n";

# OR, perhaps the best:
my @field_names = qw/ body hour minute second /;
my %matches;
@matches{ @field_names } = /(\w+)\s+(\d+h)\s(\d+m)\s(\d+s)/; # Hash Slice
print "$_: $matches{$_}\n" for keys %matches;
---------------------------------


Since you're using m//x, space characters are normally ignored. If you
do not want them to be treated normally (ignored) then you must
escape them.

I personally never use /h\ /.

I would instead use either /h[ ]/ or maybe /h\s/.

With /x, it's different than the s/// because spaces are significant there.


You misunderstand something, but I'm not sure what...

m//x and s///x do NOT treat the pattern any differently.

My suggestions apply to patterns used in either operator.
 
E

Eric Pozharski

He did copy-paste (as you would have seen yourself if you had read the rest
of my (or his) posting). He just just copy-pasted one character too
little (or too much), splitting a sub-pattern in half. Which could
either be just a copy-paste error (indicating sloppy editing) or a
failure to understand how regular expressions are constructed.

My fault.
 
S

sln

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.

Dropping this reply in the outter reply structure. From the inner posts
it looks like you just are trying to learn regular expressions.
Therefore, the set of data would present a significant formatting project
to cut your teeth on. This is probably a good thing.

After a point you would look at this data and try to factor out the real
things you want here, instead of redundant groupings. The fact is that
you don't need to validate numbers, letters, locations in the parsing regular
expression as this can be done later.

What each data line is in reality is either a group of numbers or a group
of letters. The letters can only be at the end or beginning.

So beginning or end its either ^[a-z] or [a-z]$
In the middle its [\d.+-]

Put them together with an or '|' and you have the parsing regex. Its that simple.
Validate later if you really need to.

There is no need to make Mount Everest out of a mole hill.
This one's for free George.

sln

-----------------------------------------------------
use strict;
use warnings;

my @fldnames = ('fld01','fld02','fld03','fld04','fld05','fld06','fld07','fld08','fld09','fld10');
my @Records = ();

while (<DATA>)
{
# Strip leading/trailing white space's
s/^\s*//; s/\s*$//;
next if (!length());

# Parse regex, only get whats needed
my @rec = /(^\s*[a-z]+|[\d.+-]+|[a-z]+\s*$)/ig;

# Parse regex alternate, with look ahead
# ---------------------
# or
# my @rec = /(^\s*[a-z]+|[\d.+-]+|[a-z]+?(?=\s*$))/ig;
# ---------------------

# Validate record size
next if (@rec != 10);

# Store record into a hash struct, put ref into Records array
my %struct;
@struct{ @fldnames } = @rec;
push (@Records,\%struct);

# Some debug printing
print "\n$_\n";
print "@rec\n";
print "$_ = $struct{$_}\n" for (sort keys %struct);

}

# Do something with 'Records' structures
# ...


__DATA__

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


__END__

Output:

Sun 18h 41m 55s -23? 5.4' 0.983 10.215 52.155 Up
Sun 18 41 55 -23 5.4 0.983 10.215 52.155 Up
fld01 = Sun
fld02 = 18
fld03 = 41
fld04 = 55
fld05 = -23
fld06 = 5.4
fld07 = 0.983
fld08 = 10.215
fld09 = 52.155
fld10 = Up

Mercury 20h 2m 16s -22? 12.5' 1.102 22.537 37.668 Up
Mercury 20 2 16 -22 12.5 1.102 22.537 37.668 Up
fld01 = Mercury
fld02 = 20
fld03 = 2
fld04 = 16
fld05 = -22
fld06 = 12.5
fld07 = 1.102
fld08 = 22.537
fld09 = 37.668
fld10 = Up

Venus 21h 55m 33s -14? 16.3' 0.795 39.872 11.703 Up
Venus 21 55 33 -14 16.3 0.795 39.872 11.703 Up
fld01 = Venus
fld02 = 21
fld03 = 55
fld04 = 33
fld05 = -14
fld06 = 16.3
fld07 = 0.795
fld08 = 39.872
fld09 = 11.703
fld10 = Up

Moon 21h 17m 19s -15? 2.4' 62.4 ER 36.796 22.871 Up
Moon 21 17 19 -15 2.4 62.4 36.796 22.871 Up
fld01 = Moon
fld02 = 21
fld03 = 17
fld04 = 19
fld05 = -15
fld06 = 2.4
fld07 = 62.4
fld08 = 36.796
fld09 = 22.871
fld10 = Up

Mars 18h 11m 59s -24? 6.1' 2.431 4.552 56.184 Up
Mars 18 11 59 -24 6.1 2.431 4.552 56.184 Up
fld01 = Mars
fld02 = 18
fld03 = 11
fld04 = 59
fld05 = -24
fld06 = 6.1
fld07 = 2.431
fld08 = 4.552
fld09 = 56.184
fld10 = Up

Jupiter 20h 3m 35s -20? 49.4' 6.034 23.867 38.203 Up
Jupiter 20 3 35 -20 49.4 6.034 23.867 38.203 Up
fld01 = Jupiter
fld02 = 20
fld03 = 3
fld04 = 35
fld05 = -20
fld06 = 49.4
fld07 = 6.034
fld08 = 23.867
fld09 = 38.203
fld10 = Up

Saturn 11h 32m 59s +5? 8.6' 9.018 -47.333 157.471 Set
Saturn 11 32 59 +5 8.6 9.018 -47.333 157.471 Set
fld01 = Saturn
fld02 = 11
fld03 = 32
fld04 = 59
fld05 = +5
fld06 = 8.6
fld07 = 9.018
fld08 = -47.333
fld09 = 157.471
fld10 = Set

Uranus 23h 21m 30s -4? 57.9' 20.421 48.328 -18.527 Up
Uranus 23 21 30 -4 57.9 20.421 48.328 -18.527 Up
fld01 = Uranus
fld02 = 23
fld03 = 21
fld04 = 30
fld05 = -4
fld06 = 57.9
fld07 = 20.421
fld08 = 48.328
fld09 = -18.527
fld10 = Up

Neptune 21h 39m 30s -14? 22.8' 30.748 38.963 16.599 Up
Neptune 21 39 30 -14 22.8 30.748 38.963 16.599 Up
fld01 = Neptune
fld02 = 21
fld03 = 39
fld04 = 30
fld05 = -14
fld06 = 22.8
fld07 = 30.748
fld08 = 38.963
fld09 = 16.599
fld10 = Up

Pluto 18h 4m 34s -17? 44.5' 32.543 7.443 62.142 Up
Pluto 18 4 34 -17 44.5 32.543 7.443 62.142 Up
fld01 = Pluto
fld02 = 18
fld03 = 4
fld04 = 34
fld05 = -17
fld06 = 44.5
fld07 = 32.543
fld08 = 7.443
fld09 = 62.142
fld10 = Up
 
L

Larry Gates

My fault.

I thought that the decimal point was how the fields in the regex broke up,
so when I had /.*/, I thought the asterisk was the first character.

I've learned a lot of perl in a couple weeks here. With regexes, there so
much to know that you can hardly gauge how much you don't know of it. I've
read for at least an hour a day in the camel book and spent several hours a
day on my machine, and all I can do is just a little bit more than I could
the last time I hit it.

I hope one day to have a Helen Keller water moment with the whole thing.

Cheers,
--
larry gates

And other operators aren't so special syntactically, but weird
in other ways, like "scalar", and "goto".
-- Larry Wall in <[email protected]>
 
L

Larry Gates

Yes, I know, but the OP wants to split on whitespace in this case. :)

This is what I've got now:

my $filename = 'eph6.txt';
my $filename2 = 'outfile1.txt';
open(my $fh, '<', $filename) or die "cannot open $filename: $!";
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 $gh $line;
print STDOUT $line;
}
close($fh);

seek($gh,0,0);

while (my $line = <$gh>) {

my @s = split / /, $line;

# print $gh $line;
print STDOUT @s;
}

close($gh);

# perl reg2.pl

I've got 2 questions:

q1) How do I loop over @s and print them out with a delimiter to see if I
have what I think I have? One response is, "how many times do we have to
tell you this?" I think the answer is at least 3; I can't figure it out
and have tried serially.

q2) How do I write to $gh and replace thw entire file, even if there are
fewer characters in the replacer?


--
larry gates

The choice of approaches could be made the responsibility of the
programmer.
-- Larry Wall in <[email protected]>
 
S

sln

I thought that the decimal point was how the fields in the regex broke up,
so when I had /.*/, I thought the asterisk was the first character.

I've learned a lot of perl in a couple weeks here. With regexes, there so
much to know that you can hardly gauge how much you don't know of it. I've
read for at least an hour a day in the camel book and spent several hours a
day on my machine, and all I can do is just a little bit more than I could
the last time I hit it.

I hope one day to have a Helen Keller water moment with the whole thing.

Cheers,

Unfortunately, you have wasted alot of peoples time at your expense.
Why don't you take Perl education classes, or just learn from books where
its all there in front of your eyes. Do your eyes deceive you?

Unique questions are ok, and will get you over the hurdle where your stuck,
but you have a psychological problem, the need to have your hand held online.

You are truly an attention troll.

sln
 
T

Tad J McClellan

Larry Gates said:
With regexes, there so
much to know that you can hardly gauge how much you don't know of it. I've
read for at least an hour a day in the camel book and spent several hours a
day on my machine, and all I can do is just a little bit more than I could
the last time I hit it.


If you are willing to trade money for (saved) time, buy:

"Mastering Regular Expressions"

http://regex.info
 
T

Tad J McClellan

open(my $gh, $filename2) or die "cannot open $filename2: $!";


Do you intend for the filehandle to be opened for input or for output?

(it is opened for input here.)

print $gh $line;


You are attempting to use it for output here.



You should always enable warnings when developing Perl code!


#!/usr/bin/perl
use warnings;
use strict;

while (my $line = <$gh>) {


.... and now for input.

my @s = split / /, $line;

I've got 2 questions:

q1) How do I loop over @s and print them out with a delimiter to see if I
have what I think I have? One response is, "how many times do we have to
tell you this?" I think the answer is at least 3; I can't figure it out
and have tried serially.


print "'$_'\n" for @s;

don't even need @s:

print "'$_'\n" for split / /, $line;


print "'$_'\n" for @s;

don't even need @s:

print "'$_'\n" for split / /, $line;


print "'$_'\n" for @s;

don't even need @s:

print "'$_'\n" for split / /, $line;


q2) How do I write to $gh


A first step would be to get it opened for output...

and replace thw entire file, even if there are
fewer characters in the replacer?

perldoc -f truncate
 
U

Uri Guttman

LG> while (my $line = <$fh>) {
LG> $line =~ s/\t/ /g;
LG> $line =~ s/ER/ /g;
LG> $line =~ s/°/ /g;
LG> print $gh $line;
LG> print STDOUT $line;
LG> }
LG> close($fh);

LG> seek($gh,0,0);

LG> while (my $line = <$gh>) {

this is insane. why are you fixing up the input, writing it to a file
and then reading in the file again??? just read in the original file and
fix up the data and split it. you are using fortran and batch logic here.

i didn't follow this thread closely but seeing you want to learn seek()
piqued my interest.

uri
 
T

Tim Greer

Larry said:
This is what I've got now:

my $filename = 'eph6.txt';
my $filename2 = 'outfile1.txt';
open(my $fh, '<', $filename) or die "cannot open $filename: $!";
open(my $gh, $filename2) or die "cannot open $filename2: $!";

Did you mean to open that above $filename2 for write?
while (my $line = <$fh>) {
$line =~ s/\t/ /g;
$line =~ s/ER/ /g;
$line =~ s/°/ /g;

Why are you replacing \t with " "? I might have missed why in a
previous post of yours?
print $gh $line;

You are printing to the $gh filehandle, yet you didn't open it for write
above.
print STDOUT $line;

Just print $line. STDOUT is default.
}
close($fh);
seek($gh,0,0);
while (my $line = <$gh>) {

my @s = split / /, $line;

# print $gh $line;

You still have $gh open, are stepping through it with while, and then
print to it as you're stepping through it?

print STDOUT @s;

You don't need STDOUT, though if you specifically want to specify it,
you can.
}

close($gh);

I have more questions about the above code, but this is just getting
more confusing.
# perl reg2.pl

I've got 2 questions:

q1) How do I loop over @s and print them out with a delimiter to see
if I
have what I think I have? One response is, "how many times do we have
to
tell you this?" I think the answer is at least 3; I can't figure it
out and have tried serially.

Use for() on @s. Why are you wanting to put the values in @s just to
check what you can already check when you're stepping through the file
with what's in $line?

q2) How do I write to $gh and replace thw entire file, even if there
are fewer characters in the replacer?

That depends on how you are opening it for writing and reading. I'm
confused about the method you've chosen to use in the above code. You
never opened $gh for write. I don't know if once you do redirect for
write if you'll see the file containing the data you want. I'm just
going by your last post above in reply to me, I didn't read this entire
thread, so I hestitate to try and offer answers.
 
P

Peter J. Holzer

q1) How do I loop over @s and print them out with a delimiter to see if I
have what I think I have? One response is, "how many times do we have to
tell you this?" I think the answer is at least 3; I can't figure it out
and have tried serially.

If you think we have told you already why don't you reread previous
messages and see what you find? And if you did so and found nothing (or
found something you don't understand), why don't you say so?

hp
 
L

Larry Gates

If you think we have told you already why don't you reread previous
messages and see what you find? And if you did so and found nothing (or
found something you don't understand), why don't you say so?

hp

As an example, peter, this works, and shows that my data is being split on
the right fields:

while (my $line = <$gh>) {

my @s = split / /, $line;


{ local $" = ':';
print "@s\n";
}

print STDOUT @s;
}

# sample output:

Venus:::22h:51m:18s:::-7::46.9':::0.691:::10.142:::72.919:::Up
Venus22h51m18s-746.9'0.69110.14272.919Up

Pluto:::18h:6m:40s:::-17::44.9':::32.485:::-52.833:::108.052:::Set
Pluto18h6m40s-1744.9'32.485-52.833108.052Set

So now I want to take the second element of s and hit it with

s2 = s/h/ /;

, but I can't figure out how to deal with these perl arrays like I'm
accustomed to with C or fortran. I make progress, but I never seem to
mature with how perl control structures interact with arrays.

As a work-around, I made explicit variables in the split:

my $filename = 'eph6.txt';
my $filename2 = 'outfile1.txt';
open(my $fh, '<', $filename) or die "cannot open $filename: $!";
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 $gh $line;
print STDOUT $line;
}
close($fh);

seek($gh,0,0);

while (my $line = <$gh>) {

my ($s1,$s2,$s3,$s4,$s5,$s6,
$s7,$s8,$s9,$s10) = split / /, $line;

print "s2 is $s2\n";

}

close($gh);

# perl reg7.pl

Now I get nothing:

C:\MinGW\source>perl reg7.pl
Sun 19h 43m 51s -21 17.8' 0.984 -35.020 87.148 Set
Mercury 20h 36m 41s -16 59.3' 0.747 -22.075 84.236 Set
Venus 22h 51m 18s -7 46.9' 0.691 10.142 72.919 Up
Moon 10h 24m 21s +7 29.5' 58.6 -4.992 -102.785 Set
Mars 18h 58m 51s -23 33.8' 2.398 -45.280 90.860 Set
Jupiter 20h 17m 22s -20 8.1' 6.082 -27.618 83.843 Set
Saturn 11h 32m 29s +5 16.0' 8.806 -19.672 -111.729 Set
Uranus 23h 23m 12s -4 46.5' 20.638 18.211 70.235 Up
Neptune 21h 41m 17s -14 13.9' 30.892 -7.527 77.864 Set
Pluto 18h 6m 40s -17 44.9' 32.485 -52.833 108.052 Sets2 is
s2 is
s2 is
s2 is
s2 is
s2 is
s2 is
s2 is
s2 is
s2 is

C:\MinGW\source>

??:-(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top