On Apr 28, 2012, Shawn H Corey wrote:
> Moral of the story: use meaningful variable names.
Yep, you're right. =:\ I thought it was going to be a simple question
about the unless statement. Turns out I was headed down the wrong path, so I
changed the variable name to make it clear. Ne
On 04/28/2012 01:28 PM, Shawn H Corey wrote:
On 12-04-28 12:36 PM, Uri Guttman wrote:
that reduces to just:
my $host = $mail_field || 'localhost' ;
which is the classic defaulting style. it has one flaw, it makes '' and
0 not allowed for values in $mail_field. but i doubt those would ever be
g
On 12-04-28 12:36 PM, Uri Guttman wrote:
that reduces to just:
my $host = $mail_field || 'localhost' ;
which is the classic defaulting style. it has one flaw, it makes '' and
0 not allowed for values in $mail_field. but i doubt those would ever be
good host names so it should be fine here. you
On 04/28/2012 12:10 PM, Jim Gibson wrote:
On Apr 28, 2012, at 9:04 AM, sono...@fannullone.us wrote:
my $host = 'localhost';
if ( defined ($mail_field) and ($mail_field ne '') ) {
$host = $mail_field;
}
I would use:
my $host = $mail_field ? $mail_field : 'localhost' ;
that reduces
On Sat, Apr 28, 2012 at 12:16:57PM -0400, Shawn H Corey wrote:
> On 12-04-28 12:10 PM, Jim Gibson wrote:
>>
>> On Apr 28, 2012, at 9:04 AM, sono...@fannullone.us wrote:
>>
>>> my $host = 'localhost';
>>>
>>> if ( defined ($mail_field) and ($mail_field ne '') ) {
>>> $host = $mail_field;
>>> }
>
On 12-04-28 12:10 PM, Jim Gibson wrote:
On Apr 28, 2012, at 9:04 AM, sono...@fannullone.us wrote:
my $host = 'localhost';
if ( defined ($mail_field) and ($mail_field ne '') ) {
$host = $mail_field;
}
I would use:
my $host = $mail_field ? $mail_field : 'localhost' ;
Well, since
On Apr 28, 2012, at 9:04 AM, sono...@fannullone.us wrote:
> my $host = 'localhost';
>
> if ( defined ($mail_field) and ($mail_field ne '') ) {
> $host = $mail_field;
> }
I would use:
my $host = $mail_field ? $mail_field : 'localhost' ;
--
To unsubscribe, e-mail: beginners-unsubscr...@
On Apr 28, 2012, Lesley Binks wrote:
> To be robust, you might need to check that $xtra is defined AND has something
> sensible in it using a regexp.
Well, after being set straight to the error of my ways, I finally have
code that seems to work in any situation:
my $mail_field; # set
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
On Apr 28, 2012, at 10:40 AM, sono...@fannullone.us wrote:
> On Apr 28, 2012, at 7:32 AM, Lesley Binks wrote:
>
>> Says the $host identifier will be assigned the value 'localhost' only if
>> $extra
>> is not defined.
>>
>> But $extra is defined as 'mail.example.com' so $host won't be.
>
>
wrote in message news:65c0134b-14b8-4912-a22c-d92389b0b...@fannullone.us...
Hi Shlomi,
Thanks for getting back to me.
What you should do is:
[CODE]
my $host;
unless (defined($xtra))
{
$host = 'localhost';
}
Unfortunately, that gives me the same error. I had tried it before, but I
was just
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';
$host = $xtra if (length $xtra > 0);
Can anyone see any holes in this code?
Marc
--
On 12-04-28 10:16 AM, sono...@fannullone.us wrote:
I'm having a problem with the following code:
#!/usr/bin/perl
use strict;
use warnings;
my $xtra = 'mail.example.com';
my $host = 'localhost' unless (defined ($xtra));
# this is the same as saying:
my $xtra = 'mail.example.com';
my
Shlomi,
> It's a bad idea to declare variables with a trailing conditional statement
Never mind my "why" question. It finally dawned on me that the unless
statement will not set the $host variable. And I thought sleeping on it would
help. :\
Marc
--
To unsubscribe, e-mail: beginners-
On Apr 28, 2012, at 7:32 AM, Lesley Binks wrote:
> Says the $host identifier will be assigned the value 'localhost' only if
> $extra
> is not defined.
>
> But $extra is defined as 'mail.example.com' so $host won't be.
That makes sense. What I'm trying to do is set $host to one of the
Hi Shlomi,
Thanks for getting back to me.
> What you should do is:
>
> [CODE]
>
> my $host;
> unless (defined($xtra))
> {
> $host = 'localhost';
> }
Unfortunately, that gives me the same error. I had tried it before,
but I was just trying for a one-liner. ;)
> It's a b
On Sat, Apr 28, 2012 at 07:16:18AM -0700, sono...@fannullone.us wrote:
> I'm having a problem with the following code:
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> my $xtra = 'mail.example.com';
>
> my $host = 'localhost' unless (defined ($xtra));
>
> print $host;
>
> I ge
On 04/28/2012 09:16 AM, sono...@fannullone.us wrote:
I'm having a problem with the following code:
#!/usr/bin/perl
use strict;
use warnings;
my $xtra = 'mail.example.com';
my $host = 'localhost' unless (defined ($xtra));
print $host;
I get the message "Use of uninitialized va
Hi Marc,
On Sat, 28 Apr 2012 07:16:18 -0700
sono...@fannullone.us wrote:
> I'm having a problem with the following code:
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> my $xtra = 'mail.example.com';
>
> my $host = 'localhost' unless (defined ($xtra));
>
It's a bad idea to declar
I'm having a problem with the following code:
#!/usr/bin/perl
use strict;
use warnings;
my $xtra = 'mail.example.com';
my $host = 'localhost' unless (defined ($xtra));
print $host;
I get the message "Use of uninitialized value $host in print". Does
anyone know why this doesn'
20 matches
Mail list logo