Using the ternary operator to concat a string not working like I think?

2012-04-03 Thread Stan N/A
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 exemplifying the issue: -code- #!/

Re: Using the ternary operator to concat a string not working like I think?

2012-04-03 Thread timothy adigun
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 some critical point, but perhaps thi

Re: Using the ternary operator to concat a string not working like I think?

2012-04-03 Thread Steve Bertrand
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's a short 14 line script exem

Re: Using the ternary operator to concat a string not working like I think?

2012-04-03 Thread Steve Bertrand
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

Re: Using the ternary operator to concat a string not working like I think?

2012-04-04 Thread Uri Guttman
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'm sure I'm m

Re: Using the ternary operator to concat a string not working like I think?

2012-04-04 Thread Paul Johnson
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 > an issue with perl. Here's

Re: Using the ternary operator to concat a string not working like I think?

2012-04-04 Thread Shlomi Fish
Hi all, inspired by this thread, I’ve added this item in my “Perl Elements to Avoid” page: http://perl-begin.org/tutorials/bad-elements/#ternary_operator_instead_of_if_else I added it directly below the item about using map instead of foreach for side-effects, which exhibits a similar misunderst

Re: Using the ternary operator to concat a string not working like I think?

2012-04-04 Thread Shlomi Fish
Hi Cyril, I'm CCing the list - I hope it's OK (see the last line of my signature for more information). On Wed, 4 Apr 2012 12:22:41 -0400 Cyril Deba wrote: > Hi Shlomi, > > I did read your statement about using ternary statements. So, just to > confirm. You think that the following is a bad co

Re: Using the ternary operator to concat a string not working like I think?

2012-04-04 Thread John W. Krahn
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

Re: Using the ternary operator to concat a string not working like I think?

2012-04-05 Thread Stan
Thanks to everyone for their help! It's been very enlightening! Stan On Apr 4, 2012, at 4:51 AM, Shlomi Fish wrote: > Hi all, > > inspired by this thread, I’ve added this item in my “Perl Elements to Avoid” > page: > > http://perl-begin.org/tutorials/bad-elements/#ternary_operator_instead_of_i

Re: Using the ternary operator to concat a string not working like I think?

2012-04-07 Thread Peter Scott
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 side effects like assignme

Re: Using the ternary operator to concat a string not working like I think?

2012-04-07 Thread Uri Guttman
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