Re: set defaults as hash - once

2009-04-20 Thread Dermot
2009/4/20 Chas. Owens : > On Mon, Apr 20, 2009 at 12:26, Dermot wrote: >> 2009/4/20 Chas. Owens : >>> On Mon, Apr 20, 2009 at 11:21, Dermot wrote: >> ... > snip > > I would avoid the do {...} and just muck with %defaults directly (as I > did in the exam

Re: set defaults as hash - once

2009-04-20 Thread Chas. Owens
On Mon, Apr 20, 2009 at 12:26, Dermot wrote: > 2009/4/20 Chas. Owens : >> On Mon, Apr 20, 2009 at 11:21, Dermot wrote: > ... >>> I thought that I could say somethign >>> like, "if %defaults, return %defaults else populate %defaults and >>> re

Re: set defaults as hash - once

2009-04-20 Thread Dermot
2009/4/20 Chas. Owens : > On Mon, Apr 20, 2009 at 11:21, Dermot wrote: ... >> I thought that I could say somethign >> like, "if %defaults, return %defaults else populate %defaults and >> return". >> >> Here's the error I am getting: >>

Re: set defaults as hash - once

2009-04-20 Thread Chas. Owens
til it's reloaded/started. I thought that I could say somethign > like, "if %defaults, return %defaults else populate %defaults and > return". > > Here's the error I am getting: > > Can't modify private hash in logical or assignment (||=) at > /export/

set defaults as hash - once

2009-04-20 Thread Dermot
Hi, I am trying to initiate a hash once when the package is loaded (via modperl). I don't want to make repeated DB queries for this data so I'd like to populate the hash when my daemon starts and not again until it's reloaded/started. I thought that I could say somethign like

Re: defaults

2006-06-16 Thread Dr.Ruud
(Randal L. Schwartz) schreef: > And I came up with this: > > $variable ||= 0; # all false values become 0 > $variable &&= 1; # all true values become 1 How about this: ($variable ||= 0) &&= 1 ; or ($variable &&= 1) ||= 0 ; depending on whether you expect $variable to be fa

[OT]Re: Re: defaults @ 1149875970

2006-06-09 Thread Johan Meskens CS3 jmcs3
Intrah onat Diria .. 09 Jun 2006 08:10:11 -0700 , Randal L. Schwartz wrote "Revera y": > x-mayan-date: Long count = 12.19.13.6.13; tzolkin = 9 Ben; haab = 6 Zotz .. the following could be unreadable @ 1149876152 ::: _ , / , > , 982 , "tome" , > , i

Re: defaults

2006-06-09 Thread Randal L. Schwartz
> ""Dr" == "Dr Ruud" writes: "Dr> And q{0 but true} and q{0e0} and q{0e1} etc. become 1 as well. Exactly what I wanted, yes. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing,

Re: defaults

2006-06-09 Thread Randal L. Schwartz
> ""Mr" == "Mr Shawn H Corey" <[EMAIL PROTECTED]> writes: "Mr> How about? "Mr> $variable = 1 - !$variable; Same problem. And you'll also get a warnings error. There is *no promise* in the Perl docs that a boolean returns a specific value for "true" or "false". Any code that depends on s

Re: defaults

2006-06-09 Thread Dr.Ruud
(Randal L. Schwartz) schreef: > There's an &&=, and I thought I'd never use it. > > However, one day, I realized that I needed to "normalize" the > "true/false" value of a variable, because I wanted to reduce all > possible true/false values to just 1/0 for easy operations in the > next step of th

Re: defaults

2006-06-09 Thread Mr. Shawn H. Corey
On Fri, 2006-09-06 at 09:54 -0400, Mr. Shawn H. Corey wrote: > How about? > > $variable = 1 - !$variable; And, of course, to calculate its inverse: $variable = 1 - !!$variable; -- __END__ Just my 0.0002 million dollars worth, --- Shawn "For the things we have to learn before we c

Re: defaults

2006-06-09 Thread Mr. Shawn H. Corey
On Fri, 2006-09-06 at 06:10 -0700, Randal L. Schwartz wrote: > > ""John" == "John W Krahn" <[EMAIL PROTECTED]> writes: > > "John> Wouldn't > > "John> $variable = !!$variable; > > "John> work just as well? > > No. There's no promise that the output of ! is "0" and "1". In fact, >

Re: defaults

2006-06-09 Thread Randal L. Schwartz
> ""John" == "John W Krahn" <[EMAIL PROTECTED]> writes: "John> Wouldn't "John> $variable = !!$variable; "John> work just as well? No. There's no promise that the output of ! is "0" and "1". In fact, it's "" and "1". And that's exactly what I was trying to avoid. Don't confuse C

RE: defaults

2006-06-07 Thread Timothy Johnson
-Original Message- From: Bryan R Harris [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 07, 2006 4:43 PM To: Beginners Perl Subject: Re: defaults > > > Take this (lame) example of an RSVP to an invitation: > > ** > $_ = "Bil

Re: defaults

2006-06-07 Thread Bryan R Harris
** $_ = "Bill, 3"; # name, number of folks attending (optional, defaults to 1) ($name,$numfolks) = m/([^,]+),?\s*(\d*)/; $numfolks ||= 1; ** This works fine unless Bill enters "Bill, 0" (trying to say that he

Re: defaults

2006-06-07 Thread John W. Krahn
Randal L. Schwartz wrote: >>"Bryan" == Bryan R Harris <[EMAIL PROTECTED]> writes: > > Bryan> Is there an "&&=" also? How about "or="? > > There's an &&=, and I thought I'd never use it. > > However, one day, I realized that I needed to "normalize" the "true/false" > value of a variable, bec

Re: defaults

2006-06-07 Thread Randal L. Schwartz
> "Bryan" == Bryan R Harris <[EMAIL PROTECTED]> writes: Bryan> Is there an "&&=" also? How about "or="? There's an &&=, and I thought I'd never use it. However, one day, I realized that I needed to "normalize" the "true/false" value of a variable, because I wanted to reduce all possible tru

Re: defaults

2006-06-06 Thread John W. Krahn
Bryan R Harris wrote: > >>>Can someone explain what: >>> >>>$pi ||= 3; >>> >>>...means? I just saw it in Programming Perl (pp 540), but it doesn't >>>explain it. Thx! >>|| is the logical OR operator (see perldoc perlop) which says that if $pi is >>TRUE then keep the current value of $pi but if $

RE: defaults

2006-06-06 Thread Charles K. Clarkson
Bryan R Harris wrote: : Is there an "&&=" also? How about "or="? All perl operators are listed in the 'perlop' file. HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 Don't tread on my bandwidth. Trim your posts. -- To unsubscribe, e

Re: defaults

2006-06-06 Thread Bryan R Harris
>> Can someone explain what: >> >> $pi ||= 3; >> >> ...means? I just saw it in Programming Perl (pp 540), but it doesn't >> explain it. Thx! > > || is the logical OR operator (see perldoc perlop) which says that if $pi is > TRUE then keep the current value of $pi but if $pi is FALSE then ass

Re: defaults

2006-06-06 Thread John W. Krahn
Bryan R Harris wrote: > > Can someone explain what: > > $pi ||= 3; > > ...means? I just saw it in Programming Perl (pp 540), but it doesn't > explain it. Thx! || is the logical OR operator (see perldoc perlop) which says that if $pi is TRUE then keep the current value of $pi but if $pi is FAL

defaults

2006-06-06 Thread Bryan R Harris
Can someone explain what: $pi ||= 3; ...means? I just saw it in Programming Perl (pp 540), but it doesn't explain it. Thx! - B -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]