Hi,

I wrote the following:

#!/usr/bin/perl -wT

use strict;

my ($server) = sitemode("test");
print $server;

sub sitemode {
    my $string = "foonky";
    my $server = shift || $string =~ /(foo|bar)/ ? $1 : 'default';
    return $server;
}

Now this throws an error. The error does not occur when I call the subroutine 
without an argument:

sitemode();

It also does not show up if I enclose the ternary operator in brackets:

my $server = shift || ($string =~ /(foo|bar)/ ? $1 : 'default');

While this solves my problem, I still do not get the reason for it. Could 
someone shed a light on this precedence confusion?

Thanks,

Jan
-- 
There are two major products that come out of Berkeley: LSD and UNIX. We don't 
believe this to be a coincidence. - Jeremy S. Anderson

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to