SPUG: declarations
Dave Cross
dave at dave.org.uk
Mon Jan 1 04:54:20 CST 2001
At 02:17 01/01/2001, Greg McCarroll wrote:
>* 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'};
Or cut out the middle man and write:
my $server = $in{server} || 'default.mydomain.com';
Happy new year Seattle,
Dave...
--
<http://www.dave.org.uk> SMS: sms at dave.org.uk
<plug>Data Munging with Perl <http://www.manning.com/cross/></plug>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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