error printing page using LWP::Simple

Discussion in 'Perl Misc' started by Larry Gates, Feb 4, 2009.

  1. Larry Gates

    Larry Gates Guest

    use strict;
    use warnings;
    use LWP::Simple;

    # load the complete content of the url in question
    # via LWP::Simple::get(...)

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

    print "t is $t";

    # perl scraper2.pl

    C:\MinGW\source>perl scraper2.pl
    Use of uninitialized value in concatenation (.) or string at scraper2.pl
    line 14
    ..
    t is
    C:\MinGW\source>

    I would have expected $t to have the whole page. What gives?
    --
    larry gates

    tmps_base = tmps_max; /* protect our mortal string */
    -- Larry Wall in stab.c from the perl source code
    Larry Gates, Feb 4, 2009
    #1
    1. Advertising

  2. Larry Gates

    Larry Gates Guest

    On Thu, 05 Feb 2009 12:07:06 -0800, Tim Greer wrote:

    > Larry Gates wrote:
    >
    >> On Thu, 05 Feb 2009 07:43:31 -0600, Chris Mattern wrote:
    >>
    >>> On 2009-02-05, Larry Gates <> wrote:
    >>>>
    >>>> # use strict;
    >>>
    >>> Why?

    >>
    >> That's an example of me trying things to make it work, and as I run
    >> out of
    >> guesses, the thing I post is the ugliest version I had.:-( This is a
    >> proper post:
    >>
    >> C:\MinGW\source>perl scraper2.pl
    >> Use of uninitialized value in concatenation (.) or string at
    >> scraper2.pl line 12
    >> .
    >> t is
    >> C:\MinGW\source>type scraper2.pl
    >> use strict;
    >> use warnings;
    >> use LWP::Simple;
    >>
    >> # load the complete content of the url in question
    >> # via LWP::Simple::get(...)
    >>
    >> my $t = get 'http://www.fourmilab.ch/cgi-
    >> bin/
    >> Yoursky?z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
    >> # this is line 11
    >> print "t is $t";
    >> # perl scraper2.pl
    >>
    >> C:\MinGW\source>]
    >>
    >> Is it not a problem that the url is folded over with newlines?

    >
    >
    > I assumed the new lines were due to you posting with your news client
    > wrapping the text? Anyway, as I mentioned before, assign a value to
    > the variable before you try and assign the data from get().
    >
    > I.e.,
    >
    > my $t = 'Something went wrong!';
    > $t = get 'http://domain-and-url-here';
    > print "t is $t\n";
    >
    > Have you tried this yet? Is your example domain and URL actually
    > wrapping in your script, or just when you post it here?


    I think I've got a bead on it now:


    use warnings;
    use LWP::Simple;

    # load the complete content of the url in question
    # via LWP::Simple::get(...)

    my $t = 'Something went right!';
    print "t is $t\n"; use strict;

    $t = get 'http://domain-and-url-here';
    print "t is $t\n"; use strict;

    $t = get 'http://www.fourmilab.ch/cgi-
    bin/
    Yoursky?z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
    # this is line 11
    print "t is $t";
    # perl scraper3.pl
    # end script begin output

    C:\MinGW\source>perl scraper3.pl
    t is Something went right!
    Use of uninitialized value in concatenation (.) or string at scraper3.pl
    line 12
    ..
    t is
    Use of uninitialized value in concatenation (.) or string at scraper3.pl
    line 18
    ..
    t is
    C:\MinGW\source>

    #end output begin comment

    I get the same error with your site as I did. Given that Gunnar has said
    that I might be asking a site for more information than it elects, in its
    kindness, to give me, I'll switch sites and see how that fares.

    Thanks and cheers,
    --
    larry gates

    I'm reminded of the day my daughter came in, looked over my shoulder at
    some Perl 4 code, and said, "What is that, swearing?"
    -- Larry Wall in <>
    Larry Gates, Feb 6, 2009
    #2
    1. Advertising

  3. Larry Gates

    Tim Greer Guest

    Larry Gates wrote:

    > On Thu, 05 Feb 2009 12:07:06 -0800, Tim Greer wrote:
    >
    >> Larry Gates wrote:
    >>
    >>> On Thu, 05 Feb 2009 07:43:31 -0600, Chris Mattern wrote:
    >>>
    >>>> On 2009-02-05, Larry Gates <> wrote:
    >>>>>
    >>>>> # use strict;
    >>>>
    >>>> Why?
    >>>
    >>> That's an example of me trying things to make it work, and as I run
    >>> out of
    >>> guesses, the thing I post is the ugliest version I had.:-( This is
    >>> a proper post:
    >>>
    >>> C:\MinGW\source>perl scraper2.pl
    >>> Use of uninitialized value in concatenation (.) or string at
    >>> scraper2.pl line 12
    >>> .
    >>> t is
    >>> C:\MinGW\source>type scraper2.pl
    >>> use strict;
    >>> use warnings;
    >>> use LWP::Simple;
    >>>
    >>> # load the complete content of the url in question
    >>> # via LWP::Simple::get(...)
    >>>
    >>> my $t = get 'http://www.fourmilab.ch/cgi-
    >>> bin/
    >>> Yoursky?z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
    >>> # this is line 11
    >>> print "t is $t";
    >>> # perl scraper2.pl
    >>>
    >>> C:\MinGW\source>]
    >>>
    >>> Is it not a problem that the url is folded over with newlines?

    >>
    >>
    >> I assumed the new lines were due to you posting with your news client
    >> wrapping the text? Anyway, as I mentioned before, assign a value to
    >> the variable before you try and assign the data from get().
    >>
    >> I.e.,
    >>
    >> my $t = 'Something went wrong!';
    >> $t = get 'http://domain-and-url-here';
    >> print "t is $t\n";
    >>
    >> Have you tried this yet? Is your example domain and URL actually
    >> wrapping in your script, or just when you post it here?

    >
    > I think I've got a bead on it now:
    >
    >
    > use warnings;
    > use LWP::Simple;
    >
    > # load the complete content of the url in question
    > # via LWP::Simple::get(...)
    >
    > my $t = 'Something went right!';
    > print "t is $t\n"; use strict;
    >
    > $t = get 'http://domain-and-url-here';
    > print "t is $t\n"; use strict;
    >
    > $t = get 'http://www.fourmilab.ch/cgi-
    > bin/
    > Yoursky?z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
    > # this is line 11
    > print "t is $t";
    > # perl scraper3.pl
    > # end script begin output
    >
    > C:\MinGW\source>perl scraper3.pl
    > t is Something went right!
    > Use of uninitialized value in concatenation (.) or string at
    > scraper3.pl line 12
    > .
    > t is
    > Use of uninitialized value in concatenation (.) or string at
    > scraper3.pl line 18
    > .
    > t is
    > C:\MinGW\source>
    >
    > #end output begin comment
    >
    > I get the same error with your site as I did. Given that Gunnar has
    > said that I might be asking a site for more information than it
    > elects, in its kindness, to give me, I'll switch sites and see how
    > that fares.
    >
    > Thanks and cheers,


    I've not used this, but neither $t = 'value'; $t = get $url; NOR $t =
    get $url or "value" will work (you'll just get different errors). See
    my follow up from earlier; You'll need to use $t = (get $url or
    "value"); instead -- that does work after trying.

    For example (saving word wrap):

    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" or "Problem");
    print "t is $t\n";

    Try that.
    --
    Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
    Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
    and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
    Industry's most experienced staff! -- Web Hosting With Muscle!
    Tim Greer, Feb 6, 2009
    #3
  4. Larry Gates

    Larry Gates Guest

    On Thu, 05 Feb 2009 20:50:36 -0800, Tim Greer wrote:

    > Larry Gates wrote:


    [considering another route]
    > I've not used this, but neither $t = 'value'; $t = get $url; NOR $t =
    > get $url or "value" will work (you'll just get different errors). See
    > my follow up from earlier; You'll need to use $t = (get $url or
    > "value"); instead -- that does work after trying.
    >
    > For example (saving word wrap):
    >
    > 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" or "Problem");
    > print "t is $t\n";
    >
    > Try that.


    That's looking sexy, Tim, I'll take a look when real life doesn't involver
    sexy susan. Peace,
    --
    larry gates

    Well, enough clowning around. Perl is, in intent, a cleaned up and
    summarized version of that wonderful semi-natural language known as
    "Unix".
    -- Larry Wall in <>
    Larry Gates, Feb 6, 2009
    #4
  5. Larry Gates

    Tim Greer Guest

    Larry Gates wrote:

    > On Thu, 05 Feb 2009 20:50:36 -0800, Tim Greer wrote:
    >
    >> Larry Gates wrote:

    >
    > [considering another route]
    >> I've not used this, but neither $t = 'value'; $t = get $url; NOR $t =
    >> get $url or "value" will work (you'll just get different errors).
    >> See my follow up from earlier; You'll need to use $t = (get $url or
    >> "value"); instead -- that does work after trying.
    >>
    >> For example (saving word wrap):
    >>
    >> 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" or "Problem");
    >> print "t is $t\n";
    >>
    >> Try that.

    >
    > That's looking sexy, Tim, I'll take a look when real life doesn't
    > involver
    > sexy susan. Peace,


    You can also use:

    my $t = get $url || "There was a problem";

    An alternative without the parenthesis. I just gave that in reply to
    the other suggestion someone made (you'd need to use them with a
    literal "or", so that's the same thing). I'd write it as I did just
    now above, with ||, personally (instead of using "or").
    --
    Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
    Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
    and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
    Industry's most experienced staff! -- Web Hosting With Muscle!
    Tim Greer, Feb 6, 2009
    #5
  6. Tim Greer <> writes:

    > This is why I suggested defining it and assigning a value first ($t =
    > "Someting went wrong!", so if it fails, it will show that, but I think
    > both methods would fail, actually.


    I read this like you proposing to write something like this:

    my $t = "Something is wrong";
    $t = get("http://example.com/");

    This would still leave $t with the value undef if the get request
    failed and would still give the 'uninitialized variable' warning when
    $t is used.

    But

    my $t = get("http://example.com/)
    or "Fail!";

    works correctly as you (and others) has suggested.

    //Makholm
    Peter Makholm, Feb 6, 2009
    #6
  7. Tim Greer wrote:
    > Larry Gates wrote:
    >> On Thu, 05 Feb 2009 20:50:36 -0800, Tim Greer wrote:
    >>> You'll need to use $t = (get $url or
    >>> "value"); instead -- that does work after trying.


    Works? Well, sort of. It assigns "value" to $t if $url does not contain
    a true value, but if $url contains a true value, it does not tell
    whether the get() function succeeds or why it fails.

    > You can also use:
    >
    > my $t = get $url || "There was a problem";


    Same objection.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Feb 6, 2009
    #7
  8. Gunnar Hjalmarsson <> writes:

    > Tim Greer wrote:
    >> Larry Gates wrote:
    >>> On Thu, 05 Feb 2009 20:50:36 -0800, Tim Greer wrote:
    >>>> You'll need to use $t = (get $url or
    >>>> "value"); instead -- that does work after trying.

    >
    > Works? Well, sort of. It assigns "value" to $t if $url does not
    > contain a true value, but if $url contains a true value, it does not
    > tell whether the get() function succeeds or why it fails.


    Corrent. If the content of the url happens to be "" or "0" this
    fails. You have to use the defined-or operator. This still don't allow
    you to find out *why* get() failed, but this is becaus get() is a
    simple interface that wont tell you that.

    >> my $t = get $url || "There was a problem";


    my $t = get($url) // "Fail!";

    Uhmmm, we don't have a low precedence version of '//'?

    //Makholm
    Peter Makholm, Feb 6, 2009
    #8
  9. Larry Gates <> wrote:
    > On Thu, 05 Feb 2009 12:07:06 -0800, Tim Greer wrote:
    >
    >> Larry Gates wrote:
    >>
    >>> On Thu, 05 Feb 2009 07:43:31 -0600, Chris Mattern wrote:
    >>>
    >>>> On 2009-02-05, Larry Gates <> wrote:
    >>>>>
    >>>>> # use strict;
    >>>>
    >>>> Why?
    >>>
    >>> That's an example of me trying things to make it work,



    Commenting out "use strict" is COUNTER to making things work, as
    its proper use helps to find bugs.

    The correct approach is to understand and correct the messages
    that "use strict" generates.

    This can most often be accomplished by adding 3 characters, "my ",
    in front of the first use of every variable in the program.


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


    >>> Is it not a problem that the url is folded over with newlines?



    Yes, that is absolutely a problem. So fix it.


    > use warnings;
    > use LWP::Simple;
    >
    > # load the complete content of the url in question
    > # via LWP::Simple::get(...)
    >
    > my $t = 'Something went right!';
    > print "t is $t\n"; use strict;
    >
    > $t = get 'http://domain-and-url-here';
    > print "t is $t\n"; use strict;



    "use strict" is a compile-time directive, so it happens *before*
    the print happens.

    It will only be included once, so invoking it more than once
    does not do anything at all.

    The proper place for a single invocation of "use strict" is up near
    the top of your program along with "use warnings".

    If you wonder what "use strict" does, you can read its documentation with:

    perldoc strict


    > I get the same error with your site as I did.



    If you call get() with a bad URL it will not work.

    If get's arg has newlines that are not supposed to be there, it will fail.

    If get's arg is a non-existant resource, it will fail.

    What does your web browser do when you paste "http://domain-and-url-here"
    into its location bar?

    It is *supposed* to fail, so it does.


    --
    Tad McClellan
    email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
    Tad J McClellan, Feb 6, 2009
    #9
  10. Larry Gates

    Dave Weaver Guest

    On Fri, 06 Feb 2009 10:02:01 +0100, Peter Makholm <> wrote:
    > Tim Greer <> writes:
    >
    > > This is why I suggested defining it and assigning a value first ($t =
    > > "Someting went wrong!", so if it fails, it will show that, but I think
    > > both methods would fail, actually.

    >
    > I read this like you proposing to write something like this:
    >
    > my $t = "Something is wrong";
    > $t = get("http://example.com/");
    >
    > This would still leave $t with the value undef if the get request
    > failed and would still give the 'uninitialized variable' warning when
    > $t is used.
    >
    > But
    >
    > my $t = get("http://example.com/)
    > or "Fail!";
    >
    > works correctly as you (and others) has suggested.


    You have a problem there - "or" has lower precedence than "=".

    ITYM:

    my $t = get("http://example.com/)
    || "Fail!";

    or
    my $t = get("http://example.com/)
    or print "Fail!";
    Dave Weaver, Feb 6, 2009
    #10
  11. Larry Gates

    Tim Greer Guest

    Peter Makholm wrote:

    > Tim Greer <> writes:
    >
    >> This is why I suggested defining it and assigning a value first ($t =
    >> "Someting went wrong!", so if it fails, it will show that, but I
    >> think both methods would fail, actually.

    >
    > I read this like you proposing to write something like this:
    >
    > my $t = "Something is wrong";
    > $t = get("http://example.com/");


    I replied a few minutes after saying he's need to either:

    my $t = get("http://example.com/" or "Something is wrong");

    Or, better IMO:

    my $t = get "http://example.com/" || "Something is wrong";

    > This would still leave $t with the value undef if the get request
    > failed and would still give the 'uninitialized variable' warning when
    > $t is used.


    Yes, that is true.

    > But
    >
    > my $t = get("http://example.com/)
    > or "Fail!";
    >
    > works correctly as you (and others) has suggested.


    That works, too. :)

    --
    Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
    Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
    and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
    Industry's most experienced staff! -- Web Hosting With Muscle!
    Tim Greer, Feb 6, 2009
    #11
  12. Larry Gates

    Tim Greer Guest

    Gunnar Hjalmarsson wrote:

    > Tim Greer wrote:
    >> Larry Gates wrote:
    >>> On Thu, 05 Feb 2009 20:50:36 -0800, Tim Greer wrote:
    >>>> You'll need to use $t = (get $url or
    >>>> "value"); instead -- that does work after trying.

    >
    > Works? Well, sort of. It assigns "value" to $t if $url does not
    > contain a true value, but if $url contains a true value,


    That was in reply to someone that suggested get $url or "error", which
    wouldn't work unless you put parenthesis. That's why I said "If you
    use that, you could do this..."

    my $t = get ($url) or "error"; would make more sense.

    > it does not
    > tell whether the get() function succeeds or why it fails.


    Right.

    >> You can also use:
    >>
    >> my $t = get $url || "There was a problem";

    >
    > Same objection.
    >


    True.
    --
    Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
    Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
    and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
    Industry's most experienced staff! -- Web Hosting With Muscle!
    Tim Greer, Feb 6, 2009
    #12
  13. Larry Gates

    Tim Greer Guest

    Gunnar Hjalmarsson wrote:

    >> my $t = get $url || "There was a problem";

    >
    > Same objection.


    By the way, I'm not familiar with this module and function, simply
    because I've not used it before myself (I use other solutions), but I'm
    curious what the objection above is? As in, I realize it doesn't say
    why it failed, but I didn't see any method to have it report the
    failure... I mean, since it just returns undefined if there's a
    failure.
    --
    Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
    Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
    and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
    Industry's most experienced staff! -- Web Hosting With Muscle!
    Tim Greer, Feb 6, 2009
    #13
  14. Larry Gates

    Larry Gates Guest

    On Thu, 05 Feb 2009 20:50:36 -0800, Tim Greer wrote:

    > 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" or "Problem");
    > print "t is $t\n";


    Big pimpin, Tim.

    use strict;
    use warnings;
    use LWP::Simple;

    # load the complete content of the url in question
    # via LWP::Simple::get(...)

    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 = 'Something went right!';
    print "t is $t\n";

    $t = (get "$site_url?$url_args" or "Problem");


    print "t is $t\n";


    # perl scraper3.pl

    #end script show target

    <td>
    <input type="text" name="jd" value="2454869.37545" size="20"

    How do I grab the julian date from this? Full page listing after sig.
    --
    larry gates

    Just put in another goto, and then it'll be readable. :)
    -- Larry Wall in <>

    <area shape="rect" coords="470,20,545,95" alt="38.5566,213.285"
    href="/cgi-bin/Y
    ourtel?lat=38.5566&amp;ns=North&amp;lon=213.285&amp;fov=45&amp;z=1" />
    <area shape="rect" coords="470,95,545,170" alt="40.2684,232.160"
    href="/cgi-bin/
    Yourtel?lat=40.2684&amp;ns=North&amp;lon=232.160&amp;fov=45&amp;z=1" />
    <area shape="rect" coords="470,170,545,245" alt="35.3917,253.395"
    href="/cgi-bin
    /Yourtel?lat=35.3917&amp;ns=North&amp;lon=253.395&amp;fov=45&amp;z=1" />
    <area shape="rect" coords="470,245,545,320" alt="23.0317,270.958"
    href="/cgi-bin
    /Yourtel?lat=23.0317&amp;ns=North&amp;lon=270.958&amp;fov=45&amp;z=1" />
    <area shape="rect" coords="470,320,545,395" alt="5.7588,282.432"
    href="/cgi-bin/
    Yourtel?lat=5.7588&amp;ns=North&amp;lon=282.432&amp;fov=45&amp;z=1" />
    <area shape="rect" coords="470,395,545,470" alt="-12.8447,288.823"
    href="/cgi-bi
    n/Yourtel?lat=12.8447&amp;ns=South&amp;lon=288.823&amp;fov=45&amp;z=1" />
    <area shape="rect" coords="470,470,545,545" alt="-30.1303,291.429"
    href="/cgi-bi
    n/Yourtel?lat=30.1303&amp;ns=South&amp;lon=291.429&amp;fov=45&amp;z=1" />
    <area shape="rect" coords="470,545,545,619" alt="-44.8154,290.856"
    href="/cgi-bi
    n/Yourtel?lat=44.8154&amp;ns=South&amp;lon=290.856&amp;fov=45&amp;z=1" />
    <area shape="rect" coords="545,20,619,95" alt="26.4997,216.082"
    href="/cgi-bin/Y
    ourtel?lat=26.4997&amp;ns=North&amp;lon=216.082&amp;fov=45&amp;z=1" />
    <area shape="rect" coords="545,95,619,170" alt="25.7463,229.749"
    href="/cgi-bin/
    Yourtel?lat=25.7463&amp;ns=North&amp;lon=229.749&amp;fov=45&amp;z=1" />
    <area shape="rect" coords="545,170,619,245" alt="20.6382,244.148"
    href="/cgi-bin
    /Yourtel?lat=20.6382&amp;ns=North&amp;lon=244.148&amp;fov=45&amp;z=1" />
    <area shape="rect" coords="545,245,619,320" alt="10.8382,256.796"
    href="/cgi-bin
    /Yourtel?lat=10.8382&amp;ns=North&amp;lon=256.796&amp;fov=45&amp;z=1" />
    <area shape="rect" coords="545,320,619,395" alt="-2.3921,266.127"
    href="/cgi-bin
    /Yourtel?lat=2.3921&amp;ns=South&amp;lon=266.127&amp;fov=45&amp;z=1" />
    <area shape="rect" coords="545,395,619,470" alt="-16.9564,271.889"
    href="/cgi-bi
    n/Yourtel?lat=16.9564&amp;ns=South&amp;lon=271.889&amp;fov=45&amp;z=1" />
    <area shape="rect" coords="545,470,619,545" alt="-30.9728,274.380"
    href="/cgi-bi
    n/Yourtel?lat=30.9728&amp;ns=South&amp;lon=274.380&amp;fov=45&amp;z=1" />
    <area shape="rect" coords="545,545,619,619" alt="-43.2794,273.825"
    href="/cgi-bi
    n/Yourtel?lat=43.2794&amp;ns=South&amp;lon=273.825&amp;fov=45&amp;z=1" />
    </map>
    <center><h1>Sky above 355'N 10639'3&quot;W at Fri 2009 Feb 6 21:00
    UTC</h1></c
    enter>
    <center>
    <a href="/yoursky/help/sky.html"><em><font size="-1">Explain symbols in the
    map.
    </font></em></a><br />
    <img
    src="/cgi-bin/Yoursky?di=993798CF5A500FD0F5203A94A187DA027397F0AB1B0A1AEAC0
    15D57B1F667D586C4450676C349655D73C3607D5C3B1C2655E87486371C1D7DB4DC369B8420AE695
    6B14B20E776E571CA9B59F28B7684ADF735EEB8A" usemap="#telmap" ismap="ismap"
    width="
    640" height="640" border="0" alt="Map of sky above 355'N 10639'3&quot;W
    at Fri
    2009 Feb 6 21:00 UTC" /><br />
    <em>Click in map to aim telescope.</em>
    <br /><a
    href="/cgi-bin/Yourhorizon?lat=35.083600&amp;lon=106.651000&amp;azimuth
    =0&amp;z=2&amp;elements="><b>View horizon at this observing site.</b></a>
    </center>
    <form method="post" name="request" action="/cgi-bin/Yoursky">
    <center>

    <input type="submit" value="Update" />

    <p />

    <a href="/yoursky/help/controls.html"><em>Explain controls in the following
    pane
    l.</em></a>
    <table border="border" cellpadding="5">

    <tr>
    <th>
    <a href="/yoursky/help/controls.html#DateTime"><b>Date and
    Time</b></a>
    </th>
    <td>
    <table>
    <tr>
    <td>
    <input type="radio" name="date" onclick="0" checked="checked" value="0" />
    <a hr
    ef="/yoursky/help/controls.html#Now">Now</a>
    </td>
    </tr>
    <tr>
    <td>
    <input type="radio" name="date" onclick="0" value="1" /> <a
    href="/yoursky/help/
    controls.html#UTC">Universal time:</a>
    </td>
    <td>
    <input type="text" name="utc" value="2009-02-06 21:00:39" size="20"
    onchange="do
    cument.request.date[1].checked=true;" />
    </td>
    </tr>
    <tr>
    <td>
    <input type="radio" name="date" onclick="0" value="2" /> <a
    href="/yoursky/help/
    controls.html#Julian">Julian day:</a>
    </td>
    <td>
    <input type="text" name="jd" value="2454869.37545" size="20"
    onchange="document.
    request.date[2].checked=true;" />
    </td>
    </tr>
    </table>

    </td>
    </tr>
    <tr>
    <th>
    <a href="/yoursky/help/controls.html#Site">Observing Site</a>
    </th>
    <td>
    <table cellpadding="3">
    <tr>
    <td>
    Latitude:
    </td>
    <td>
    <input type="text" name="lat" value="355'" size="10" />
    </td>
    <td>
    <label><input type="radio" name="ns" checked="checked" value="North" />
    North</l
    abel>
    <label><input type="radio" name="ns" value="South" /> South</label>
    </td>
    </tr>
    <tr>
    <td>
    Longitude:
    </td>
    <td>
    <input type="text" name="lon" value="10639'3&quot;" size="10" />
    </td>
    <td>
    <label><input type="radio" name="ew" value="East" /> East</label>
    <label><input type="radio" name="ew" checked="checked" value="West" />
    West</lab
    el>
    </td>
    </tr>

    <tr>
    <td align="center">
    <a href="/yoursky/cities.html"><b>Set for nearby city</b></a>
    </td>
    </tr>

    </table>

    </td>
    </tr>
    <tr>
    <th><a href="/yoursky/help/controls.html#Options">Display Options</a>
    </th>
    <td>
    <input type="checkbox" checked="checked" name="coords" /> <a
    href="/yoursky/help
    /controls.html#Coords">Ecliptic and equator</a>

    <br />
    <input type="checkbox" checked="checked" name="moonp" /> <a
    href="/yoursky/help/
    controls.html#Planets">Moon and planets</a>

    <br />
    <input type="checkbox" checked="checked" name="deep" /> <a
    href="/yoursky/help/
    controls.html#DeepSky">Deep sky objects of magnitude</a>
    <input type="text" name="deepm" value="2.5" size="3" /> and brighter

    <br />
    <a href="/yoursky/help/controls.html#Constellations">Constellations:</a>
    <br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox"
    checked="
    checked" name="consto" /> <a
    href="/yoursky/help/controls.html#ConstO">Outlines<
    /a>
    <br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox"
    checked="
    checked" name="constn" /> <a
    href="/yoursky/help/controls.html#ConstN">Names</a>

    <label><input type="checkbox" name="consta" /> aligned with
    horizon?</label>
    <br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox"
    checked="
    checked" name="constb" /> <a
    href="/yoursky/help/controls.html#ConstB">Boundarie
    s</a>

    <br />
    <a href="/yoursky/help/controls.html#Stars">Stars:</a>
    <br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
    href="/yoursky/help/controls.
    html#StarMag">Show stars brighter than magnitude</a>
    <input type="text" name="limag" value="5.5" size="3" />
    <br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox"
    checked="
    checked" name="starn" /> <a
    href="/yoursky/help/controls.html#StarName">Names fo
    r magnitude</a>
    <input type="text" name="starnm" value="2.0" size="3" /> and brighter
    <br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox"
    checked="
    checked" name="starb" /> <a
    href="/yoursky/help/controls.html#StarBFlam">Bayer/F
    lamsteed codes</a> for mag.
    <input type="text" name="starbm" value="2.5" size="3" /> and brighter

    <br /><input type="checkbox" name="flip" /> <a
    href="/yoursky/help/controls.html
    #Invert">Invert North and South</a>

    <br /><a href="/yoursky/help/controls.html#Imgsize">Image size</a>: <input
    type=
    "text" name="imgsize" value="640" size="6" /> pixels

    <br /><a href="/yoursky/help/controls.html#Scheme">Colour scheme</a>:
    <select na
    me="scheme" size="1">
    <option value="0" selected="selected">Colour</option>
    <option value="1">Black on white background</option>
    <option value="2">White on black background</option>
    <option value="3">Night vision (red)</option>
    </select>

    </td>
    </tr>
    <tr>
    <th><a href="/yoursky/help/elements.html">Asteroid and<br />Comet
    Tracking</a
    >

    </th>
    <td align="center">
    <br />
    Paste <a href="/yoursky/help/elements.html">orbital elements</a> below:
    <label><input type="checkbox" name="edump" value="-xe" /> Echo
    elements</label
    >

    <br />
    <textarea name="elements" rows="1" cols="40">
    </textarea><br />
    </td>
    </tr>
    </table>

    </center>
    </form>

    <p />
    <a href="/yoursky/help/ephemeris.html"><b>Ephemeris:</b></a><center>
    <table border="border" cellpadding="3">
    <tr><th rowspan="2">&nbsp;</th><th rowspan="2">Right<br />Ascension</th><th
    rows
    pan="2">Declination</th><th rowspan="2">Distance<br />(<span
    title="Astronomical
    units (149,597,871 km)">AU</span>)</th><th colspan="2">From 355'N
    10639'3&quo
    t;W:</th></tr>
    <tr><th>Altitude</th><th>Azimuth</th></tr>
    <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=0&amp;z=1">Sun</a></th><td
    align="ri
    ght">21h 22m 35s</td><td align="right">&minus;15 22.3'</td><td
    align="right">0.
    986</td><td align="right">34.252</td><td
    align="right">29.521</td><td>Up</td></t
    r>
    <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=1&amp;z=1">Mercury</a></th><td
    align
    ="right">19h 40m 10s</td><td align="right">&minus;19 45.0'</td><td
    align="right
    ">0.863</td><td align="right">17.140</td><td
    align="right">49.551</td><td>Up</td
    ></tr>

    <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=2&amp;z=1">Venus</a></th><td
    align="
    right">0h 7m 4s</td><td align="right">+3 25.6'</td><td
    align="right">0.516</td>
    <td align="right">54.988</td><td
    align="right">&minus;28.916</td><td>Up</td></tr
    >

    <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=3&amp;z=1">Moon</a></th><td
    align="r
    ight">6h 46m 2s</td><td align="right">+25 35.2'</td><td align="right">57.0
    <spa
    n title="Earth radii (6378.14 km)">ER</span></td><td
    align="right">&minus;4.237<
    /td><td align="right">&minus;125.539</td><td>Set</td></tr>
    <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=4&amp;z=1">Mars</a></th><td
    align="r
    ight">20h 16m 46s</td><td align="right">&minus;20 44.0'</td><td
    align="right">2
    ..336</td><td align="right">21.729</td><td
    align="right">41.785</td><td>Up</td></
    tr>
    <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=5&amp;z=1">Jupiter</a></th><td
    align
    ="right">20h 40m 29s</td><td align="right">&minus;18 49.2'</td><td
    align="right
    ">6.067</td><td align="right">26.429</td><td
    align="right">37.876</td><td>Up</td
    ></tr>

    <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=6&amp;z=1">Saturn</a></th><td
    align=
    "right">11h 28m 50s</td><td align="right">+5 45.5'</td><td
    align="right">8.530<
    /td><td align="right">&minus;48.690</td><td
    align="right">170.062</td><td>Set</t
    d></tr>
    <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=7&amp;z=1">Uranus</a></th><td
    align=
    "right">23h 27m 5s</td><td align="right">&minus;4 21.0'</td><td
    align="right">2
    0.923</td><td align="right">50.147</td><td
    align="right">&minus;9.577</td><td>Up
    </td></tr>
    <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=8&amp;z=1">Neptune</a></th><td
    align
    ="right">21h 44m 39s</td><td align="right">&minus;13 57.0'</td><td
    align="right
    ">31.015</td><td align="right">37.604</td><td
    align="right">24.097</td><td>Up</t
    d></tr>
    <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=9&amp;z=1">Pluto</a></th><td
    align="
    right">18h 9m 47s</td><td align="right">&minus;17 44.2'</td><td
    align="right">3
    2.271</td><td align="right">2.886</td><td
    align="right">65.911</td><td>Up</td></
    tr>
    </table>
    </center>
    <blockquote>
    <small>Azimuth in the above table
    follows the astronomical convention: zero
    degrees is South with positive angles toward the
    West and negative angles toward the East.</small>
    </blockquote><p />
    <a href="/yoursky/#Skymap"><b>Back to <em>Sky Maps</em></b></a>
    &nbsp;&nbsp;<a href="/yoursky/"><b>Up to <em>Your Sky</em></b></a>
    &nbsp;&nbsp;<a href="/yoursky/credits.html"><b>Credits</b></a>
    &nbsp;&nbsp;<a href="/yoursky/custom.html"><b>Customise</b></a>
    &nbsp;&nbsp;<a href="/yoursky/help/help.html"><b>Help</b></a>
    <p />
    <hr />
    <address>
    by <a href="/">John Walker</a>
    </address>
    <p />
    <blockquote>
    <font size="-1"><em>Images produced by Your Sky are in the public
    domain and may be used in any manner without permission, restriction,
    attribution, or compensation. Back links to
    <a href="http://www.fourmilab.ch/yoursky/">Your Sky</a> are
    welcome.</em></font>

    </blockquote>
    </body>
    </html>


    C:\MinGW\source>
    Larry Gates, Feb 6, 2009
    #14
  15. Larry Gates

    Larry Gates Guest

    On Fri, 6 Feb 2009 06:53:28 -0600, Tad J McClellan wrote:

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

    >
    >>>> Is it not a problem that the url is folded over with newlines?

    >
    >
    > Yes, that is absolutely a problem. So fix it.


    I've asked this question before and didn't get an answer I could use. How
    does a person do proper line continuations in perl?
    --
    larry gates

    So please don't think I have a "down" on the MVS people. I'm just pulling
    off their arms to beat other people over the head with.
    -- Larry Wall in <>
    Larry Gates, Feb 6, 2009
    #15
  16. Larry Gates

    Tim Greer Guest

    Larry Gates wrote:

    > On Thu, 05 Feb 2009 20:50:36 -0800, Tim Greer wrote:
    >
    >> 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" or "Problem");
    >> print "t is $t\n";

    >
    > Big pimpin, Tim.
    >
    > use strict;
    > use warnings;
    > use LWP::Simple;
    >
    > # load the complete content of the url in question
    > # via LWP::Simple::get(...)
    >
    > 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 = 'Something went right!';
    > print "t is $t\n";
    >
    > $t = (get "$site_url?$url_args" or "Problem");
    >
    >
    > print "t is $t\n";
    >
    >
    > # perl scraper3.pl
    >
    > #end script show target
    >
    > <td>
    > <input type="text" name="jd" value="2454869.37545" size="20"
    >
    > How do I grab the julian date from this? Full page listing after sig.


    Well, first of all that was just in response to someone mentioning or,
    I'd change the code:

    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" || "There was a problem".

    I'd also consider using something else, like useragent, so you know what
    the problem was, instead of just having it be undefined. Sometimes you
    can act on the problem, or at least know not to try again if it's
    forbidden on the target site, or whatever else.

    You can grab the Julian date with something like:

    my $juldate = ($t =~ m/name="jd" value="([^"]+)"/) ? $1 : "No date";

    Of course, there are dozens of ways of doing this.
    --
    Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
    Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
    and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
    Industry's most experienced staff! -- Web Hosting With Muscle!
    Tim Greer, Feb 6, 2009
    #16
  17. Larry Gates

    Tim Greer Guest

    Larry Gates wrote:

    > On Fri, 6 Feb 2009 06:53:28 -0600, Tad J McClellan wrote:
    >
    >>>>> my $t = get 'http://www.fourmilab.ch/cgi-
    >>>>> bin/
    >>>>> Yoursky?z=1&lat=35.0836&ns=North&lon=106.651&ew=West';

    >>
    >>>>> Is it not a problem that the url is folded over with newlines?

    >>
    >>
    >> Yes, that is absolutely a problem. So fix it.

    >
    > I've asked this question before and didn't get an answer I could use.
    > How does a person do proper line continuations in perl?


    Probably, something like:

    my $t = get(
    'http://www.fourmilab.ch/cgi-bin/Yoursky?' .
    'z=1&lat=35.0836&ns=North&lon=106.651&ew=West'
    ) || "There was a problem.";
    print "t is $t\n";

    Would work.

    The other methods are as I mentioned before. Set a variable for the
    domain, URL and args and just pass it to get() that way.

    --
    Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
    Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
    and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
    Industry's most experienced staff! -- Web Hosting With Muscle!
    Tim Greer, Feb 6, 2009
    #17
  18. Larry Gates

    Larry Gates Guest

    On Fri, 6 Feb 2009 15:44:24 -0600, Tad J McClellan wrote:

    > Larry Gates <> wrote:
    >> On Fri, 6 Feb 2009 06:53:28 -0600, Tad J McClellan wrote:
    >>
    >>>>>> my $t = get 'http://www.fourmilab.ch/cgi-
    >>>>>> bin/
    >>>>>> Yoursky?z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
    >>>
    >>>>>> Is it not a problem that the url is folded over with newlines?
    >>>
    >>>
    >>> Yes, that is absolutely a problem. So fix it.

    >>
    >> I've asked this question before and didn't get an answer I could use. How
    >> does a person do proper line continuations in perl?

    >
    >
    > By pressing the wide key labeled "Enter" or "Return" on your keyboard. :)
    >
    >
    > If you instead meant to ask how to get a really long string that
    > does not hit the wordwrap limit, then use the concatenation operator:
    >
    > my $t = get 'http://www.fourmilab.ch/cgi-'
    > . 'bin/'
    > . 'Yoursky?z=1&lat=35.0836&ns=North&lon=106.651&ew=West';


    That explains the error expecting a period.

    Hoe does a perl program say read lines until one of them contains 'jd', and
    indeed if it contains this tring, then it's the only one wecare about for
    now.

    My hands are injured.
    --
    larry gates

    Real theology is always rather shocking to people who already
    think they know what they think. I'm still shocked myself. :)
    -- Larry Wall in <>
    Larry Gates, Feb 8, 2009
    #18
  19. Larry Gates <> wrote:


    > Hoe does a perl program say read lines until one of them contains 'jd',



    Are you serious, or are you joking around?

    while ( <> ) {
    last if /jd/;
    }
    print "There is a jd in this line: $_";


    --
    Tad McClellan
    email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
    Tad J McClellan, Feb 8, 2009
    #19
  20. Larry Gates

    Larry Gates Guest

    On Sat, 7 Feb 2009 23:42:23 -0600, Tad J McClellan wrote:

    > Larry Gates <> wrote:
    >
    >
    >> Hoe does a perl program say read lines until one of them contains 'jd',

    >
    >
    > Are you serious, or are you joking around?
    >
    > while ( <> ) {
    > last if /jd/;
    > }
    > print "There is a jd in this line: $_";


    No, I'm not kidding. It's new syntax for me.

    Dietrich Bonhoefeer spoke of the last, and the penultimate, dat Vorletzte.

    If you canbump execution back oneline, can you capture what lies onthe same
    line with 'jd'.
    --
    larry gates

    And you can still put in all that cruft if you want to. You can even
    force yourself to have to do it. But to me, it feels a bit like slavery,
    so I'm still looking for a land flowing with milk and honey, even if
    there are a few giants in it. -- Larry Wall
    Larry Gates, Feb 8, 2009
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon B
    Replies:
    7
    Views:
    7,483
    =?Utf-8?B?SmFzb25DaG9p?=
    Jan 30, 2006
  2. Peder Ydalus

    setting http-referrer using LWP::Simple?

    Peder Ydalus, Jan 27, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    161
  3. Arvin Portlock

    Using LWP to get last modified date of web page

    Arvin Portlock, Jun 4, 2004, in forum: Perl Misc
    Replies:
    4
    Views:
    345
    Richard Bell
    Jun 8, 2004
  4. bhabs
    Replies:
    2
    Views:
    369
    Tad J McClellan
    Feb 13, 2008
  5. David Karr
    Replies:
    9
    Views:
    874
    David Karr
    Aug 25, 2011
Loading...

Share This Page