Re: Ternary operator

2009-09-11 Thread Robert H
On 9/11/09 5:49 PM, Chas. Owens wrote: On Fri, Sep 11, 2009 at 17:28, Telemachus wrote: Yep, 3rd edition (which to my knowledge was the last version) was published in 2000 and therefore can only cover up to Perl 5.6. Luckily 5.8 didn't change much and 5.10 has very explicit documentation abo

Re: Ternary operator

2009-09-11 Thread Chas. Owens
On Fri, Sep 11, 2009 at 17:28, Telemachus wrote: > On Fri Sep 11 2009 @  4:16, Chas. Owens wrote: >> I love perldoc, but it does not document the language nearly as well >> as Programming Perl.  Of course, that might be why perldoc is free and >> Programming Perl costs roughly $50 USD (and weighs

Re: Ternary operator

2009-09-11 Thread Telemachus
On Fri Sep 11 2009 @ 4:16, Chas. Owens wrote: > I love perldoc, but it does not document the language nearly as well > as Programming Perl. Of course, that might be why perldoc is free and > Programming Perl costs roughly $50 USD (and weighs a ton). There's also the problem that Programming Perl

Re: Ternary operator

2009-09-11 Thread Chas. Owens
On Fri, Sep 11, 2009 at 15:43, John W. Krahn wrote: > Chas. Owens wrote: >> >> On Fri, Sep 11, 2009 at 09:56, John W. Krahn wrote: >> snip You can't tell everything about the language from the docs. >>> >>> Give me an example, I'll point you to the docs.  (Have you read them >>> all?) >

Re: Ternary operator

2009-09-11 Thread John W. Krahn
Chas. Owens wrote: On Fri, Sep 11, 2009 at 09:56, John W. Krahn wrote: snip You can't tell everything about the language from the docs. Give me an example, I'll point you to the docs. (Have you read them all?) snip Okay, I will bite, where is it documented that (@a) x= 3; is an error? Mo

Re: Ternary operator

2009-09-11 Thread Chas. Owens
On Fri, Sep 11, 2009 at 14:54, Chas. Owens wrote: snip >> In case it isn't clear enough, my question (not directly to you, but >> to the perl maintainers) is "Where does perl document the ternary >> operator's behaviour of only evaluating either the second or the third >> argument, never both?" I

Re: Ternary operator

2009-09-11 Thread Chas. Owens
On Fri, Sep 11, 2009 at 10:36, John W. Krahn wrote: snip >> If C can document ?: properly, why can't perl? The size of each >> language has nothing to do with this. > > perldoc perlop > [ SNIP ] >       Conditional Operator > >       Ternary "?:" is the conditional operator, just as in C. > > > Yo

Re: Ternary operator

2009-09-11 Thread Chas. Owens
On Fri, Sep 11, 2009 at 10:19, Philip Potter wrote: snip >>> Perl's is not. >> >> Define "complete". > > If Perl doesn't document ?: properly, its document is not complete. snip It defines it well enough that I have never had it produce unexpected behavior. If you are unhappy with the documentat

Re: Ternary operator

2009-09-11 Thread Chas. Owens
On Fri, Sep 11, 2009 at 09:56, John W. Krahn wrote: snip >> You can't tell everything about the language from the docs. > > Give me an example, I'll point you to the docs.  (Have you read them all?) snip Okay, I will bite, where is it documented that (@a) x= 3; is an error? More generally, whe

Re: Ternary operator

2009-09-11 Thread Paul Johnson
On Fri, Sep 11, 2009 at 03:19:53PM +0100, Philip Potter wrote: > If C can document ?: properly, why can't perl? The size of each > language has nothing to do with this. > If Perl doesn't document ?: properly, its document is not complete. > In case it isn't clear enough, my question (not directl

Re: text html from file to a scalar

2009-09-11 Thread Steve Bertrand
John W. Krahn wrote: > Steve Bertrand wrote: >> John W. Krahn wrote: >>> John Plum wrote: >> #---Assemble/concatenate references in both ascii and html, to make full confirmatory message bodies with order details--- $scalar_sig = "\printFile($signature)"; >>> You can not call a

Re: text html from file to a scalar

2009-09-11 Thread John W. Krahn
Steve Bertrand wrote: John W. Krahn wrote: John Plum wrote: #---Assemble/concatenate references in both ascii and html, to make full confirmatory message bodies with order details--- $scalar_sig = "\printFile($signature)"; You can not call a subroutine from inside a string. Just the $signa

Re: Ternary operator

2009-09-11 Thread Uri Guttman
> "SB" == Steve Bertrand writes: SB> my $ret = ( $foo == 1 ) ? ( $num + $add_to ) : 2; those aren't side effects. there is no change to data in the ?: parts. SB> ...SHOULD _always_ ( where possible ) be written as: SB> my $expr_result = ( $num + $add_to ); SB> my $ret = ( $foo ==

Re: text html from file to a scalar

2009-09-11 Thread Steve Bertrand
John W. Krahn wrote: > John Plum wrote: >> May I introduce myself, John Plumridge, London, UK. > > John W. Krahn, Vancouver, Canada. Steve Bertrand, Port Hope, Ontario, Canada :) >> #---Assemble/concatenate references in both ascii and html, to make >> full confirmatory message bodies with ord

Re: Ternary operator

2009-09-11 Thread John W. Krahn
Philip Potter wrote: 2009/9/11 John W. Krahn : Philip Potter wrote: My point is that C documents its behaviour. It seems that Perl doesn't. man perl perldoc perl http://oreilly.com/catalog/9780596000271/ http://perldoc.perl.org/ perldoc -q "Is there an ISO or ANSI certified version of Perl"

Re: Ternary operator

2009-09-11 Thread Philip Potter
2009/9/11 John W. Krahn : > Philip Potter wrote: >> >> My point is that C documents its behaviour. It seems that Perl >> doesn't. > > man perl > perldoc perl > http://oreilly.com/catalog/9780596000271/ > http://perldoc.perl.org/ > perldoc -q "Is there an ISO or ANSI certified version of Perl" Do a

Re: Ternary operator

2009-09-11 Thread John W. Krahn
John W. Krahn wrote: Philip Potter wrote: 2009/9/11 Steve Bertrand : Uri Guttman wrote: it is actually very simple to understand. the key point to knowing it and how to use it is that the 2 value expressions SHOULD NOT have side effects. that means changing something by assignment or other mod

Re: Ternary operator

2009-09-11 Thread John W. Krahn
Philip Potter wrote: My point is that C documents its behaviour. It seems that Perl doesn't. man perl perldoc perl http://oreilly.com/catalog/9780596000271/ http://perldoc.perl.org/ perldoc -q "Is there an ISO or ANSI certified version of Perl" C's documentation is complete, C is a very sm

Re: Ternary operator

2009-09-11 Thread John W. Krahn
Philip Potter wrote: 2009/9/11 Steve Bertrand : Uri Guttman wrote: it is actually very simple to understand. the key point to knowing it and how to use it is that the 2 value expressions SHOULD NOT have side effects. that means changing something by assignment or other modification. your exampl

Re: Ternary operator

2009-09-11 Thread Philip Potter
2009/9/11 Steve Bertrand : > Uri Guttman wrote: >> it is actually very simple to understand. the key point to knowing it >> and how to use it is that the 2 value expressions SHOULD NOT have side >> effects. that means changing something by assignment or other >> modification. your example below is

Re: Ternary operator

2009-09-11 Thread John W. Krahn
John W. Krahn wrote: $ cat ternary-test.c #include #include char *shift ( int *argc, char **argv ) { int i; char *temp = argv[ 0 ]; for ( i = 1; i < *argc; ++i ) { argv[ i - 1 ] = argv[ i ]; } Opps, also need to adjust argc here: --*argc; return temp

Re: Ternary operator

2009-09-11 Thread John W. Krahn
Philip Potter wrote: 2009/9/11 John W. Krahn : Philip Potter wrote: Does ?: guarantee that only one arm of its conditions will be executed? eg: # @_ has 3 elements $x = $flag ? shift : push; $ perl -e'$x = $flag ? shift : push;' Not enough arguments for push at -e line 1, near "push;" Execut

Re: Ternary operator

2009-09-11 Thread Steve Bertrand
Uri Guttman wrote: Thanks to all for the fantastic feedback, and for the very detailed examples. After reading and practising them a few times, I don't think I'll ever be able to forget how to use this op anymore :) > it is actually very simple to understand. the key point to knowing it > and how

Re: text html from file to a scalar

2009-09-11 Thread John W. Krahn
John Plum wrote: HI Folk, Hello, May I introduce myself, John Plumridge, London, UK. John W. Krahn, Vancouver, Canada. - I'm still in awe of this whole creation we're in. Life? Nice to meet you. And very nice to meet you as well. I have a reason of course, for approachin

Re: Ternary operator

2009-09-11 Thread Philip Potter
2009/9/11 John W. Krahn : > Philip Potter wrote: >> Does ?: guarantee that only one arm of its conditions will be executed? >> eg: >> >> # @_ has 3 elements >> >> $x = $flag ? shift : push; > > $ perl -e'$x = $flag ? shift : push;' > Not enough arguments for push at -e line 1, near "push;" > Execut

text html from file to a scalar

2009-09-11 Thread John Plum
HI Folk, May I introduce myself, John Plumridge, London, UK. - I'm still in awe of this whole creation we're in. Nice to meet you. I have a reason of course, for approaching you, via my MTNews 'console'. What a great application! MY problem is obtaining and passing text/html from file t

Re: Ternary operator

2009-09-11 Thread John W. Krahn
Philip Potter wrote: 2009/9/11 Uri Guttman : "SB" == Steve Bertrand writes: SB> Besides consistently forgetting how to properly spell "ternary", I SB> can't, for some reason, embed it's use into my brain no matter how SB> much I read. ternary op is an official name but it has many nickname

Re: Ternary operator

2009-09-11 Thread John W. Krahn
Steve Bertrand wrote: [ forgive me if it was sent twice. My first should be bounced as bad sender addr ]. Besides consistently forgetting how to properly spell "ternary", I can't, for some reason, embed it's use into my brain no matter how much I read. It is "borrowed" from the C programming l

Re: Ternary operator

2009-09-11 Thread Philip Potter
2009/9/11 Uri Guttman : >> "SB" == Steve Bertrand writes: > >  SB> Besides consistently forgetting how to properly spell "ternary", I >  SB> can't, for some reason, embed it's use into my brain no matter how >  SB> much I read. > > ternary op is an official name but it has many nicknames so th

Re: "$| = 1" ???

2009-09-11 Thread Philip Potter
2009/9/11 Raymond Wan : > Perldoc is somewhat hard to get into...but it's the manual for a programming >  language, so that's expected; I don't think having pages to color and draw > on would be a feasible idea for the next update.  :-) I don't think you should tar every perldoc page with the same