error printing page using LWP::Simple

L

Larry Gates

Larry Gates said:
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.

Is that the conditional operator from c there? :
^^^^^^^^^^^^^^^^^^^^


I wonder if maybe there is a heading of "Conditional Operator" in

perldoc perlop

:)


Conditional Operator

Ternary "?:" is the conditional operator, just as in C. It works much
like an if-then-else. If the argument before the ? is true, the
argument
before the : is returned, otherwise the argument after the : is
returned. For example:

printf "I have %d dog%s.\n", $n,
($n == 1) ? '' : "s";

Scalar or list context propagates downward into the 2nd or 3rd
argument,
whichever is selected.

$a = $ok ? $b : $c; # get a scalar
@a = $ok ? @b : @c; # get an array
$a = $ok ? @b : @c; # oops, that's just a count!

The operator may be assigned to if both the 2nd and 3rd arguments are
legal lvalues (meaning that you can assign to them):

($a_or_b ? $a : $b) = $c;

Because this operator produces an assignable result, using assignments
without parentheses will get you in trouble. For example, this:

$a % 2 ? $a += 10 : $a += 2

Really means this:

(($a % 2) ? ($a += 10) : $a) += 2

Rather than this:

($a % 2) ? ($a += 10) : ($a += 2)

That should probably be written more simply as:

$a += ($a % 2) ? 10 : 2;

Tad--

I've got something else tonight. I fielded the following post in c.l.f.
so:

Hello Folks,

I am using Lahey FORTRAN to process several large image datasets.
Currently, I dump the resulting data to a text file which is
subsequently processed separately using a Perl script.

I am wondering if it is possible to feed the FORTRAN array directly
(from memory) to Perl or PYTHON. Can this be done? Any ideas or
suggestions?

Thanks,
TLowe.

What's your data set look like? By image do you mean the right side of a
function or something like a .bmp?

Perl is very good at simulating the activities of a Bourne shell, so if you
can describe how you'd do it on the commandline, then you're past first
base.

For me, perl is my weaker syntax, so I would do the harder stuff in fortran
first, if only to get my head around how I would work it up in perl. Once
you've got an objective and something to show as a script--it could be
minimal like inputting and outputting from a file to stdout--then you will
likely be well-treated if you post in comp.lang.perl.misc.

You'll need some time to read, once you do this, as they expect newcomers
to read anything relevant they post. In preparation, you could grab
_Programming Perl_ from the library. I call it the camel book.

I'd love to follow this, so I hope you're not a poster who rings the
doorbell only to leave a pile of flaming dogshit on the porch. I wouldn't
mind working it up in python as well. My uncle replaced the C curriculum
with python in the comp sci dept he directs. He doesn't miss C a bit.

#end excerpt

Do you have a faq for this?
--
larry gates

fail("Language designer not persuaded"); # :)
-- Larry Wall in <[email protected]>

--
larry gates

Python's syntax succeeds in combining the mistakes of Lisp and Fortran.
I do not contrue that as progress.
-- Larry Wall in <[email protected]>
 
L

Larry Gates

C:\MinGW\source>perl tree1.pl
2454875.70218

C:\MinGW\source>type tree1.pl
#!/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->find_by_attribute('name', 'jd') ) {
print $elem->attr('value'), "\n";
}

# perl tree1.pl
C:\MinGW\source>

I spent alot of time looking for a module I already had, but I see what you
mean now.

I'm gonna get the same data underneath the collision.
--
larry gates

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

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

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,734
Latest member
manin

Latest Threads

Top