On 04/07/2012 06:54 AM, Peter Scott wrote:
On Wed, 04 Apr 2012 03:04:42 -0400, Uri Guttman wrote:
that code is not a good use of ?: at all so use if/else.
Right. And if you want the single statement succinctness, use and/or:
% perl -le '%test = qw(one first two second); $test{one} eq "firs
On Wed, 04 Apr 2012 03:04:42 -0400, Uri Guttman wrote:
> On 04/03/2012 06:55 PM, timothy adigun wrote:
> that is the wrong way to fix this even if it works.
>
> the ternary operator is meant to return a single value from a choice of
> two expressions. it is not meant for si
h
>
> On Tue, 3 Apr 2012 17:39:10 -0400
> "Stan N/A" wrote:
>
>> I've run into a weird issue where the ternary operator isn't doing
>> what I believe it normally would and need some help understanding the
>> issue. I'm sure I'm missing
Shlomi Fish wrote:
Hi Cyril,
I'm CCing the list - I hope it's OK
I hate handling carbon copies, you always get that black stuff all over
your hands!
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the oppo
*
> *}*
Well, your mailer has mangled the non-HTML version of this code, but luckily I
can still read it. I don't think this is bad code because both clauses of the
ternary operators lack side-effects. People may call to func
misunderstanding.
Thanks to the original poster and all the people who replied.
Regards,
Shlomi Fish
On Tue, 3 Apr 2012 17:39:10 -0400
"Stan N/A" wrote:
> I've run into a weird issue where the ternary operator isn't doing
> what I believe it normally would and need s
On Tue, Apr 03, 2012 at 05:39:10PM -0400, Stan N/A wrote:
> I've run into a weird issue where the ternary operator isn't doing
> what I believe it normally would and need some help understanding the
> issue. I'm sure I'm missing some critical point, but perhaps this is
On 04/03/2012 06:55 PM, timothy adigun wrote:
Hi Stan,
Please check my comments below:
On Tue, Apr 3, 2012 at 10:39 PM, Stan N/A wrote:
I've run into a weird issue where the ternary operator isn't doing
what I believe it normally would and need some help understanding the
issue. I&
On 2012-04-03 18:55, timothy adigun wrote:
Hi Stan,
Please check my comments below:
$test{one} eq "first" ?
$test{one} .= " is the worst\n" :
( $test{two} .= " is the best\n");
This is not what the ternary (conditional operator) is for. As I said in
my last post, it is used f
On 2012-04-03 17:39, Stan N/A wrote:
I've run into a weird issue where the ternary operator isn't doing
what I believe it normally would and need some help understanding the
issue. I'm sure I'm missing some critical point, but perhaps this is
an issue with perl. Here'
Hi Stan,
Please check my comments below:
On Tue, Apr 3, 2012 at 10:39 PM, Stan N/A wrote:
> I've run into a weird issue where the ternary operator isn't doing
> what I believe it normally would and need some help understanding the
> issue. I'm sure I'm missing som
I've run into a weird issue where the ternary operator isn't doing
what I believe it normally would and need some help understanding the
issue. I'm sure I'm missing some critical point, but perhaps this is
an issue with perl. Here's a short 14 line script exemplify
>>>>> "CS" == Chris Stinemetz writes:
CS> I would like to make an adjustment to this ternary operator.
CS> Instead of returning 0 if length( $dist ) is not > 1. I would like to
CS> return the last $dist value incremented by 0.1 mile so there is no g
On 3/28/11 Mon Mar 28, 2011 12:44 PM, "Chris Stinemetz"
scribbled:
> I would like to make an adjustment to this ternary operator.
> Instead of returning 0 if length( $dist ) is not > 1. I would like to
> return the last $dist value incremented by 0.1 mile so there is no
I would like to make an adjustment to this ternary operator.
Instead of returning 0 if length( $dist ) is not > 1. I would like to
return the last $dist value incremented by 0.1 mile so there is no gap
of more than 0.1 miles.
$dist = sprintf "%.1f",
( length( $dist ) > 1 ) ? $di
Jim,
Thank you for the clarification and the "perl -c yourprogram.pl" tip. It works
the way I want it to now. You have been very helpful.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
At 7:01 AM -0500 3/26/11, Chris Stinemetz wrote:
>
In the statement:
if( $cell )
$cell is evaluated for true or false. All scalar values are valid in this
evaluation, including numerical, string, and undef, the three types of Perl
scalar values.
On the other hand, in this statement:
$rlp2,$rlp3,$rlp4,$dist) =
@data[31,32,38,44,45,46,47,261];
if( $cell >= 1 && $cell <= 900 ) { ... }### This is where I am
getting my runtime error
my $carr =
( $cell <= 299 && $chan == 175 ) ? 2
On 3/25/11 Fri Mar 25, 2011 1:19 PM, "Chris Stinemetz"
scribbled:
> There is no possible value of 0 for what I am trying to do. So I am
> trying to do the former example:
>
>>if( $cell ) {
You are leaving out context here, so people not familiar with this thread
will be less likely to hel
There is no possible value of 0 for what I am trying to do. So I am
trying to do the former example:
>if( $cell ) {
I am trying to code the if statement correctly, but I am getting a syntax error:
Below is how I am trying to code the if statement:
if ($cell >= 1 && $cell <= 900 ) {
On 3/25/11 Fri Mar 25, 2011 11:15 AM, "Chris Stinemetz"
scribbled:
> I am getting the warning:
>
> Argument "" isn't numeric in numeric lt (<) at ./DOband.pl line 22,
> <$fh> line 52411.
>
> It seems to be directed to the below ternary op
I am getting the warning:
Argument "" isn't numeric in numeric lt (<) at ./DOband.pl line 22,
<$fh> line 52411.
It seems to be directed to the below ternary operator:
How can I include in the ternary to ignore all non numeric values in
the elements $cell and
Chas. Owens wrote:
On Thu, Mar 24, 2011 at 16:53, Chris Stinemetz
wrote:
I have a ternary operator that I would like to be rounded to the nearest tenth
decimal
place before the array is pushed.
The proper term is conditional operator, even in C.
Rounding is a tricky subject (see
http
On Thu, Mar 24, 2011 at 16:53, Chris Stinemetz
wrote:
> I have a ternary operator that I would like to be rounded to the nearest
> tenth decimal
> place before the array is pushed.
The proper term is conditional operator, even in C.
Rounding is a tricky subject (see
http://en.wiki
On 11-03-24 04:53 PM, Chris Stinemetz wrote:
I would like the current output of my ternary operator: 2.44318181818182 to be
rounded to 2.4.
The easiest way is to use sprintf;
perl -e '$var = sprintf "%.1f", 2.44318181818182; print "$var\n";'
--
Just my 0.
I have a ternary operator that I would like to be rounded to the nearest tenth
decimal place before the array is pushed.
For example:
I would like the current output of my ternary operator: 2.44318181818182 to be
rounded to 2.4.
Below is what my code looks like:
#!/usr/bin/perl
use
>>>>> "r" == rkb writes:
r> Lawrence Statton wrote:
>>
>> On Mar 29, 2010, at 10:54 AM, r...@i.frys.com wrote:
>>>
>>> I looked through perlop and was unable to find where it
>>> stated that the ternary operator sh
Uri Guttman wrote:
>>>>>> "r" == rkb writes:
[snip]
> r> I often use the ternary operator when working with
> r> dispatch tables. Based on your comment, I suspect
> that
> r> you feel that the following example is a poor use of
> th
Lawrence Statton wrote:
>
> On Mar 29, 2010, at 10:54 AM, r...@i.frys.com wrote:
>>
>> I looked through perlop and was unable to find where it
>> stated that the ternary operator should only be used in
>> an
>> assignment such as you've shown. Can
>>>>> "r" == rkb writes:
r> Uri Guttman wrote:
>> when will people learn?? the ternary operator is for
>> CHOOSING A
>> VALUE. it is NOT for side effects. its precedence is
>> designed to allow
>> it to be assigned, NOT t
On Mar 29, 2010, at 10:54 AM, r...@i.frys.com wrote:
I looked through perlop and was unable to find where it
stated that the ternary operator should only be used in an
assignment such as you've shown. Can you point out where
that's located.
In my reasonably-arrogant opinion: T
On Mon, Mar 29, 2010 at 10:27 PM, Shlomi Fish wrote:
>>
>> No. ($foo == 1) is a list which always has a value of either 1 or 0 so
>> it really return a true value in both cases.
>
> Not true:
>
> {{{
> shlomi:~$ perl -le '$foo = 0; print +($foo == 1) ? "Foo is 1" : "Foo is not
> 1"'
> Foo is not
Uri Guttman wrote:
> when will people learn?? the ternary operator is for
> CHOOSING A
> VALUE. it is NOT for side effects. its precedence is
> designed to allow
> it to be assigned, NOT to have assignments done inside.
>
>
> NEVER USE ?: for side effects. ALWAYS use it to
>>>>> "SHC" == Shawn H Corey writes:
SHC> On Mon, 29 Mar 2010 12:25:12 -0400
SHC> "Uri Guttman" wrote:
>> when will people learn??
SHC> They can't learn to do it properly because so much Perl documentation
SHC> is out of date
On Mon, 29 Mar 2010 12:25:12 -0400
"Uri Guttman" wrote:
> when will people learn??
They can't learn to do it properly because so much Perl documentation
is out of date.
--
Just my 0.0002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is a
what $foo is.
when will people learn?? the ternary operator is for CHOOSING A
VALUE. it is NOT for side effects. its precedence is designed to allow
it to be assigned, NOT to have assignments done inside.
NEVER USE ?: for side effects. ALWAYS use it to return a value chosen
from two. do not break this
> "JP" == Jeff Peng writes:
JP> On Mon, Mar 29, 2010 at 10:02 PM, Jeff Soules wrote:
>> Hi all,
>> EX 2:
>> ($foo == 1) ?
>> $bar = 0 :
>> $bar = 1;
>>
>> These are logically equivalent, right?
JP> No. ($foo == 1) is a list which always has a value of eit
Jeff Peng wrote:
On Mon, Mar 29, 2010 at 10:02 PM, Jeff Soules wrote:
Am I missing something? I have the following chunks of code:
EX 1:
if ($foo == 1){
$bar = 0;
}else{
$bar = 1;
}
EX 2:
($foo == 1) ?
$bar = 0 :
$bar = 1;
Th
Jeff Soules wrote:
Hi all,
Hello,
Am I missing something?
Precedence.
perldoc perlop
I have the following chunks of code:
EX 1:
if ($foo == 1){
$bar = 0;
}else{
$bar = 1;
}
EX 2:
($foo == 1) ?
$bar = 0 :
$bar = 1;
These are logically eq
On Mon, 29 Mar 2010 17:27:44 +0300
Shlomi Fish wrote:
> Of course in this particular case, this is equivalent to:
>
> $bar = ($foo != 1);
>
> Unless you care about $bar specifically being 0 instead of the also
> false values of the empty-string or undef().
In that case, do this:
$bar = ( $f
>> Assignment has lower precedence than ?: It is done last.
Aha -- I was afraid of something like that.
> (I.e: put parentheses around the clauses of if statements, even though they
> are not needed or I could use the ultra-low-precedence "and"/"or"/etc.)
Good idea. I almost always do in if-st
Hi Shawn!
On Monday 29 Mar 2010 17:19:36 Shawn H Corey wrote:
> On Mon, 29 Mar 2010 10:02:15 -0400
>
> Jeff Soules wrote:
> > ($foo == 1) ?
> >
> > $bar = 0 :
> > $bar = 1;
> >
> > Am I doing something stupid or missing something obvious?
>
> ($foo == 1) ?
> ( $bar =
On Monday 29 Mar 2010 17:10:27 Jeff Peng wrote:
> On Mon, Mar 29, 2010 at 10:02 PM, Jeff Soules wrote:
> > Hi all,
> >
> > Am I missing something? I have the following chunks of code:
> >
> > EX 1:
> >if ($foo == 1){
> >$bar = 0;
> >}else{
> >$bar = 1;
> >}
> >
> >
On Mon, 29 Mar 2010 10:02:15 -0400
Jeff Soules wrote:
> ($foo == 1) ?
> $bar = 0 :
> $bar = 1;
> Am I doing something stupid or missing something obvious?
($foo == 1) ?
( $bar = 0 ) :
( $bar = 1 );
Assignment has lower precedence than ?: It is done last. Wh
Hi all,
Am I missing something? I have the following chunks of code:
EX 1:
if ($foo == 1){
$bar = 0;
}else{
$bar = 1;
}
EX 2:
($foo == 1) ?
$bar = 0 :
$bar = 1;
These are logically equivalent, right? But when I've run the latter,
$bar always com
On 29 March 2010 14:02, Jeff Soules wrote:
> Hi all,
Hiya,
> Am I missing something? I have the following chunks of code:
>
> EX 1:
> if ($foo == 1){
> $bar = 0;
> }else{
> $bar = 1;
> }
>
> EX 2:
> ($foo == 1) ?
> $bar = 0 :
> $bar = 1;
>
> These are lo
On Mon, Mar 29, 2010 at 10:02 PM, Jeff Soules wrote:
> Hi all,
>
> Am I missing something? I have the following chunks of code:
>
> EX 1:
> if ($foo == 1){
> $bar = 0;
> }else{
> $bar = 1;
> }
>
> EX 2:
> ($foo == 1) ?
> $bar = 0 :
> $bar = 1;
>
> These are
On 9/11/09 12:37 AM, Uri Guttman wrote:
whenever you see an if/else where the code just assigns one or another
value to the same variable that should be coded as a ternary op as this
is what is it designed to do:
Awesome. That is a clear and concise reasoning that even my brain can
handle.
> "Tim" == Tim Bowden writes:
Tim> Oh good, O'Reilly hasn't given up. Is there some uncertainty as to the
Tim> success a future version might have? Or is it a question of the right
Tim> resources being available and willing to undertake the task? Or has it
Tim> been put on the backburner f
On Mon, 2009-09-14 at 09:32 -0700, Randal L. Schwartz wrote:
> > "Telemachus" == Telemachus writes:
>
> Telemachus> Unfortunately, it seems like O'Reilly has given up on Perl...
>
> Absolutely not. Just that the costs of *updating* a book often approach the
> costs of initial development f
> "Telemachus" == Telemachus writes:
Telemachus> Unfortunately, it seems like O'Reilly has given up on Perl...
Absolutely not. Just that the costs of *updating* a book often approach the
costs of initial development for many of the "overhead" activities.
You lept to a conclusion that was
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
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
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
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?)
>
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
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
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
h contains every (well, not yet, but soon)
Perl operator (for some [definition][2] of the word) in its own
section.
snip
> I thought I already had! The ?: ternary operator has a guarantee that
> it will *either* evaluate its second *or* its third operand. It won't
> ever evaluate both. Wh
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
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
> "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 ==
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"
this.
>> Perl's is not.
>
> Define "complete".
If Perl doesn't document ?: properly, its document is not complete.
>> You can't tell everything about the language from the docs.
>
> Give me an example, I'll point you to the docs. (Have yo
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
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
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
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
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
ne two three four five six
In my_shift function
x = "one"
$ ./ternary-test 0 one two three four five six
In my_pop function
x = "six"
Yep, same behavior as the Perl ternary operator.
John
--
Those people who think they know everything are a great
annoyance to those of us who do.-- Isaac Asimov
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
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
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
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
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
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
> "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 they are
worth knowing too. condit
[ 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.
Perhaps if someone could show me the way against a personal code s
In a message dated 3/2/2004 9:21:57 AM Eastern Standard Time,
[EMAIL PROTECTED] writes:
>$#array + 1 still is the size of the array and it won't modify the
>array. That's not what we were talking about. We were talking about
>++$#array, which expands to $#array = $#array + 1. Note the equal s
On Mar 2, 2004, at 12:41 AM, WC -Sx- Jones wrote:
Once upon a time $#array + 1 was the size of the array; obviously
(scalar @array) now has the right size.
$#array + 1 still is the size of the array and it won't modify the
array. That's not what we were talking about. We were talking about
++
John W. Krahn wrote:
You do realise that ++$#array modifies @array?
$ perl -le'
@array = 90 .. 99;
print scalar @array;
++$#array;
print scalar @array;
++$#array;
print scalar @array;
'
10
11
12
D'Oh! Yep, it does...
Once upon a time $#array + 1 was the size of the array; obviously
(scalar @ar
Wc -Sx- Jones wrote:
>
> R. Joseph Newton wrote:
>
> > print "Greater count was $greater_count\n";
> > print "Lesser count was $lesser_count\n";
>
> But that was my point - you could just use ++$#array; because you are
> only testing sizeOf array - a true test would be to see if they are
> ident
--As of Monday, March 1, 2004 8:54 PM -0500, WC -Sx- Jones is alleged to
have said:
But that was my point - you could just use ++$#array; because you are
only testing sizeOf array - a true test would be to see if they are
identical in what each array holds.
--As for the rest, it is mine.
Only if
R. Joseph Newton wrote:
print "Greater count was $greater_count\n";
print "Lesser count was $lesser_count\n";
But that was my point - you could just use ++$#array; because you are
only testing sizeOf array - a true test would be to see if they are
identical in what each array holds.
-Bill-
__
WC -Sx- Jones wrote:
> R. Joseph Newton wrote:
>
> > Although it is not necessary the meaning might be better expressed:
> > my $n = (@$a > @$b ? @$a : @$b)
>
> Sorry for jumping in -
No problem. That's why this is a group.
> You cannot compare two arrays that way and expect them to be numerica
R. Joseph Newton wrote:
Although it is not necessary the meaning might be better expressed:
my $n = (@$a > @$b ? @$a : @$b)
Sorry for jumping in -
You cannot compare two arrays that way and expect them to be numerically
different - if they are it may be a coincidence; consider for discussion:
Andrew Gaffney wrote:
> Perl wrote:
> > I am trying to understand how this works. For example:
> >
> > my $n = @$a > @$b ? @$a : @$b;
> >
> >
> > I understand this is a conditional statement I am just not sure what is
> > being compared with ? and :.
>
> I believe that the above just assigns a tru
Andrew Gaffney wrote:
>
> Perl wrote:
> > I am trying to understand how this works. For example:
> >
> > my $n = @$a > @$b ? @$a : @$b;
> >
> > I understand this is a conditional statement I am just not sure what is
> > being compared with ? and :.
>
> I believe that the above just assigns a true
Perl wrote:
>
> I am trying to understand how this works. For example:
>
> my $n = @$a > @$b ? @$a : @$b;
>
> I understand this is a conditional statement I am just not sure what is
> being compared with ? and :.
That is same as:
my $n;
if ( @$a > @$b ) {
$n = @$a;
}
else {
$n = @$
Perl wrote:
I am trying to understand how this works. For example:
my $n = @$a > @$b ? @$a : @$b;
I understand this is a conditional statement I am just not sure what is
being compared with ? and :.
I believe that the above just assigns a true or false (1 or 0) to $n. The statement is the
same
I am trying to understand how this works. For example:
my $n = @$a > @$b ? @$a : @$b;
I understand this is a conditional statement I am just not sure what is
being compared with ? and :.
--Paul
--- Adam Turoff <[EMAIL PROTECTED]> wrote:
> On Tue, May 22, 2001 at 09:37:13AM -0700, Paul wrote:
> > Anybody know if there would likely be any problem with building a
> > "case" statement like the folowing (without installing Switch.pm)?
> >
> > sub rate ($) {
> > $_[0] eq 'A' ? .03 :
> >
--- Jeff Pinyan <[EMAIL PROTECTED]> wrote:
> On May 22, Paul said:
>
> >I know that in many C compilers, the a ? b : c construct with the
> >ternary ?: operator si not stable after the second or third nesting,
> >but I've never seen that sort of problem in te
On Tue, May 22, 2001 at 09:37:13AM -0700, Paul wrote:
> Anybody know if there would likely be any problem with building a
> "case" statement like the folowing (without installing Switch.pm)?
>
> sub rate ($) {
> $_[0] eq 'A' ? .03 :
> $_[0] eq 'B' ? .05 :
> $_[0] eq 'C' ? .06 :
>
On May 22, Paul said:
>I know that in many C compilers, the a ? b : c construct with the
>ternary ?: operator si not stable after the second or third nesting,
>but I've never seen that sort of problem in tests I've run in Perl.
The only to watch out for is precendence:
$a
Hi all.
I know that in many C compilers, the a ? b : c construct with the
ternary ?: operator si not stable after the second or third nesting,
but I've never seen that sort of problem in tests I've run in Perl.
Anybody know if there would likely be any problem with building a
"
95 matches
Mail list logo