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]>