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

I meant the "returned expression" not the "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

  • Comment on Re^3: no expected 'Useless use of a constant in void context' warning for expression in return statement
  • Select or Download Code

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
    that makes sense! thank you very much, Rolf. -Ed