On Sat, Apr 28, 2012 at 08:00:09AM -0700, sono...@fannullone.us wrote: > Shawn, > > > are you sure this is what you want? > > I'm not sure of anything anymore. ;) > > I found something that sets $host properly: > > my $xtra = 'mail.example.com'; > my $host = 'localhost'; > That's a better method of safely initialising your identifiers. > $host = $xtra if (length $xtra > 0); What this will do is assign $host the value of $xtra if $xtra has length >0. Which may possibly be what you want.
> > > Can anyone see any holes in this code? > It is sensible and advised to declare and initialise identifiers with safe default values and then sort out the conditions for any change of that initial value. I think that > $host = $xtra if (length $xtra > 0); may be better than $host = $xtra if (defined($extra)) ; because it will account for the situation where $xtra = ''; But it won't account for the situation where $xtra = ' '; To be robust, you might need to check that $xtra is defined AND has something sensible in it using a regexp. Regards Lesley > Marc > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/