in reply to Forgot variable syntax for $var = funct() or "Funct failed\n" / Any experience with is_hostname()
or is one of the lowest precedence operators, even below =. This means that your code is parsed as: (my $hostname = call()) or "Can't resolve thing"; You should use || instead, or // if your value can be defined but false.
my $hostname = call() || "Can't resolve"; my $hostname = call(); $hostname //= "Can't resolve"; # Alternative so +lution
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Forgot variable syntax for $var = funct() or "Funct failed\n";
by AnomalousMonk (Archbishop) on Jan 05, 2016 at 16:25 UTC | |
by Eily (Monsignor) on Jan 05, 2016 at 16:39 UTC | |
by AnomalousMonk (Archbishop) on Jan 05, 2016 at 18:18 UTC |