T
Tim Greer
It only took up .1 of a single IQ to figure that out. Americans.. jeez
sln
Yes, yes, "all" Americans are dumb compared to you, and "all" Americans
are the same. Okay then.
It only took up .1 of a single IQ to figure that out. Americans.. jeez
sln
Larry said:Tim,
I'd appreciate if you didn't respond to someone I, as OP, killfiled on
this
thread. Thx.
Larry said:These are not the habits of a dullard.
Jim said:my @s = split /\s+/, $line;
I agree.
Have you read "The camel has two humps"?
http://www.cs.mdx.ac.uk/research/PhDArea/saeed/paper1.pdf *
Some people fall into the "inconsistent" group - looking for meaning
where it does not exist. These people will probably not succeed as
programmers despite their intelligence and capacity for success in other
fields.
Just my ¤0.02 worth.
Hope this helps.
Larry Gates said:Constructive comments do. Adding in the NOOP lines gives me the output I'm
looking for:
use strict;
use warnings;
# open input file
my $filename = 'eph9.txt';
open(my $fh, '<', $filename) or
die "cannot open $filename for reading: $!";
# open output file
my $filename2 = 'outfile11.txt';
open(my $gh, '>', $filename2) or
die "cannot open $filename2 for writing: $!";
# process all lines in input file
while( my $line = <$fh> ) {
chomp($line);
# get rid of °, + and ER
$line =~ s/ER//g;
$line =~ s/°//g;
$line =~ s/\+//g;
my @s = split /\s+/, $line;
# modify fields
$s[1] =~ s/h//;
$s[2] =~ s/m//;
$s[3] =~ s/s//;
$s[5] =~ s/'//;
# print modified fields
for my $i (0..$#s) {
print "s[$i] = $s[$i]\n";
}
# write modified fields to output file
my $outline = join(' ', @s);
print $gh "$outline\n";
}
# close input and output files
close($gh) or die("Error closing $filename2: $!");
close($fh) or die("Error closing $filename: $!");
__END__
# perl reg15.pl
C:\MinGW\source>type outfile11.txt
Sun 20 41 55 -18 15.1 0.985 31.290 28.986 Up
Mercury 19 37 21 -18 9.2 0.703 23.506 43.890 Up
Venus 23 38 15 -1 11.5 0.589 49.918 -29.062 Up
Moon 21 48 14 -11 42.6 62.2 42.389 12.334 Up
Mars 19 44 11 -22 12.5 2.363 21.142 39.928 Up
Jupiter 20 30 48 -19 23.6 6.088 29.121 31.156 Up
Saturn 11 30 46 5 30.8 8.631 -46.580 155.929 Set
Uranus 23 25 19 -4 32.5 20.818 47.940 -22.647 Up
Neptune 21 43 12 -14 4.3 30.982 39.839 13.351 Up
Pluto 18 8 33 -17 44.6 32.377 9.447 60.368 Up
C:\MinGW\source>
I'm gonna continue this on the fortran side. This was the hardest regex
I've done by the longest of shots, and I couldn't have done it without your
(plural) help.
s[0] = Moon
s[1] = 21
s[2] = 10
s[3] = 19
s[4] = -15
s[5] = 43.1
s[6] = 62.6
s[7] = ER
s[8] = -3.535
s[9] = 73.245
s[10] = Set
Perl is much better suited for this type of
task than Fortran (I have coded in both). Sticking with Perl and
learning enough Perl to do this job would make you a better programmer.
However, they may not be your goal.
Well in fact you didn't do it at all. I and several other people had to
write the code for you.
[snip rest of code down]Hope this helps.
Constructive comments do. Adding in the NOOP lines gives me the output I'm
looking for:
use strict;
use warnings;
# open input file
my $filename = 'eph9.txt';
open(my $fh, '<', $filename) or
die "cannot open $filename for reading: $!";
# open output file
my $filename2 = 'outfile11.txt';
open(my $gh, '>', $filename2) or
die "cannot open $filename2 for writing: $!";
# process all lines in input file
while( my $line = <$fh> ) {
chomp($line);
# get rid of °, + and ER ^ why ?????????
$line =~ s/ER//g;
$line =~ s/°//g;
$line =~ s/\+//g;
my @s = split /\s+/, $line;
# modify fields
$s[1] =~ s/h//;
$s[2] =~ s/m//;
$s[3] =~ s/s//;
$s[5] =~ s/'//;
Sun 20 41 55 -18 15.1 0.985 31.290 28.986 Up
^^ ^^^I'm gonna continue this on the fortran side. This was the hardest regex
I've done by the longest of shots, and I couldn't have done it without your
(plural) help.
Above is the current ephemeris for Albuquerque. The sun is almost on top
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.