in reply to Re^2: no expected 'Useless use of a constant in void context' warning for expression in return statement
in thread no expected 'Useless use of a constant in void context' warning for expression in return statement
it's effectively
return scalar(10,20);
so no warning
DB<100> print scalar (10,20) 20
UPDATE: maybe the following is clearer,
DB<113> sub tst { 2..10 } => 0 DB<114> ($a)=tst() => 2 DB<115> $a=tst() => "" DB<116> sub tst { /2/../10/ } => 0 DB<117> $_=2 => 2 DB<118> $a=tst() => 1 DB<119> $a=tst() => 2 DB<120> $_=10 => 10 DB<121> $a=tst() => "3E0"
as you can see the range-op transforms to flip-flop-op in scalar context.
So we are not returning a list but an expression which is evaluated according to the callers context.
Cheers Rolf
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: no expected 'Useless use of a constant in void context' warning for expression in return statement
by ed_hoch (Sexton) on Dec 15, 2012 at 23:27 UTC |