SPUG: declarations

Greg McCarroll greg at mccarroll.demon.co.uk
Sun Dec 31 20:17:40 CST 2000


* David H. Adler (dha at panix.com) wrote:
> 
> My question is, why would you even have a line of code like this in a
> program at a point where %in wouldn't already exist?  And if you
> localize it as at top, you're effectively just assinging a value of
> undef to $one_server.

based on a few leaps of logic, is the question - how do i set a default
for $in{'server'} if its not already defined. if this isn't the real
question please forgive me, but i'm just joining into the guessing game
along with everyone else ....

anyway the neatest way to declare the defaults just before they are
used is (imho),

$in{'server'} ||= 'default.mydomain.com';
my $server = $in{'server'};

for more info about ||= do a search for ``orcish maneuver'' on your
favourite search engine (or better still google ;-) )

hth - but i am guessing

* DHA then wrote: 
> 
> Am I missing something?
> 

the BBC? ulster frys? good guiness? 

;-)

Greg

-- 
Greg McCarroll                          http://www.mccarroll.uklinux.net

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/





More information about the spug-list mailing list