Re: time and place of satellite coincidence



On Fri, 13 Feb 2009 23:42:26 -0600, Tad J McClellan wrote:

#!/usr/bin/perl
use warnings;
use strict;
use HTML::TreeBuilder;
use LWP::Simple;

my $site_url = 'http://www.fourmilab.ch/cgi-bin/Yoursky';
my $url_args = 'z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
my $t = get "$site_url?$url_args" || "Problem";

my $tree = HTML::TreeBuilder->new_from_content($t);

foreach my $elem ( $tree->look_down('_tag', 'center') ) {
print $elem->as_text(), "\n";

I try to balance my posts between things that have worked and things that
haven't, and I think I'm at the tipping point now.

I get output I like for part of it, but I can't extend the methods to reach
a solution. This version was working until I tried to incorporate stuff
from HTML::Element, and then I get the complaints from perl.exe:

#!/usr/bin/perl
use warnings;
use strict;
use HTML::TreeBuilder;
use LWP::Simple;



my $site_url = 'http://www.fourmilab.ch/cgi-bin/Yoursky';
my $url_args = 'z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
my $t = get "$site_url?$url_args" || "Problem";

my $tree = HTML::TreeBuilder->new_from_content($t);

foreach my $elem ( $tree->look_down('_tag', 'center') ) {

print "%%\n", $elem;
print $elem->as_text(), "\n";
}

foreach my $elem ( $tree->find_by_attribute('name', 'jd') ) {
print "****";
print $elem->attr('value'), "\n";
}

use HTML::Element;
$a = HTML::Element->new('a', href => 'http://www.perl.com/');
$a->push_content("The Perl Homepage");

$tag = $a->tag;
print "$tag starts out as:", $a->starttag, "\n";
print "$tag ends as:", $a->endtag, "\n";
print "$tag\'s href attribute is: ", $a->attr('href'), "\n";

$links_r = $a->extract_links();
print "Hey, I found ", scalar(@$links_r), " links.\n";

print "And that, as HTML, is: ", $a->as_HTML, "\n";
$a = $a->delete;



# perl index6.pl

#end script; show dump of dos windwo

C:\MinGW\source>perl index6.pl
%%
HTML::Element=HASH(0x1acf1d0)Sky above 35░5'N 106░39'3"W at Mon 2009 Feb 16
4:32
UTC
%%
HTML::Element=HASH(0x1af74f4)Explain symbols in the map.Click in map to aim
tele
scope.View horizon at this observing site.
%%
HTML::Element=HASH(0x1af78b4)Explain controls in the following panel.Date
and Ti
me Now Universal time: Julian day:Observing Site Latitude: North South
Longitud
e: East WestSet for nearby cityDisplay Options Ecliptic and equator Moon
and pl
anets Deep sky objects of magnitude and brighter Constellations: áááááááá
Outli
nes áááááááá Names aligned with horizon? áááááááá BoundariesStars:
ááááááááShow
stars brighter than magnitude áááááááá Names for magnitude and brighter
ááááá
ááá Bayer/Flamsteed codes for mag. and brighter Invert North and
SouthImage si
ze: pixels Colour scheme: ColourBlack on white backgroundWhite on black
backgro
undNight vision (red)Asteroid andComet Tracking Paste orbital elements
below: E
cho elements

%%
Wide character in print at index6.pl line 18.
HTML::Element=HASH(0x1b08cd0) RightAscensionDeclinationDistance(AU)From
35┬░5'N
106°39'3"W:AltitudeAzimuthSun21h 59m 16s−12°
17.8'0.988−45.719110.332SetM
ercury20h 15m 33s−19° 47.0'1.017−69.097132.831SetVenus0h 28m 22s+7°
18.9'0
..451−4.407102.133SetMoon15h 2m 48s−22° 37.9'62.5
ER−35.118−85.358SetMar
s20h 46m 38s−19° 1.2'2.309−63.450120.976SetJupiter20h 49m 21s−18°
16.0'6
..029−62.468121.250SetSaturn11h 26m 37s+6°
1.6'8.46024.724−79.502UpUranus23h
28m 52s−4° 9.4'21.000−23.167101.784SetNeptune21h 46m 2s−13°
50.1'31.019
−49.201111.502SetPluto18h 10m 47s−17°
43.5'32.153−68.083−138.502Set
****2454878.68916

C:\MinGW\source> perl index6.pl
Global symbol "$tag" requires explicit package name at index6.pl line 30.
Global symbol "$tag" requires explicit package name at index6.pl line 31.
Global symbol "$tag" requires explicit package name at index6.pl line 32.
Global symbol "$tag" requires explicit package name at index6.pl line 33.
Global symbol "$links_r" requires explicit package name at index6.pl line
35.
Global symbol "$links_r" requires explicit package name at index6.pl line
36.
Execution of index6.pl aborted due to compilation errors.

C:\MinGW\source>

Outside of basically not knowing my I failed here, I have 2 other
questions.

q1) I didn't see look_down as a method in HTML::TreeBuilder, HTML::Element
and one other HTML::Something that I looked for it. Where do I find a
definition of the look_down method?

q2) I *still* have problems with control structures in perl. Why does
this not print the index variable for the loop?

#!/usr/bin/perl
use warnings;
use strict;
use HTML::TreeBuilder;
use LWP::Simple;

my $site_url = 'http://www.fourmilab.ch/cgi-bin/Yoursky';
my $url_args = 'z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
my $t = get "$site_url?$url_args" || "Problem";

my $tree = HTML::TreeBuilder->new_from_content($t);

foreach my $elem ( $tree->look_down('_tag', 'center') ) {

print "%%\n", $elem;
print $elem->as_text(), "\n";
}

# perl index3.pl

Thanks for your comment.
--
larry gates

May you do Good Magic with Perl.
-- Larry Wall's blessing
.