in reply to Re: deprecated split ??
in thread deprecated split ??

Nope. split is not called in list context. The fact that it's the second to last statement in the block, and not the last, makes it get called in void context.

As a demo, runt this code:

sub foo { printf "foo(%s) called in %s context\n", join(', ', @_), wantarray ? 'list' : defined wantarray ? 'scalar' : 'void'; } @dummy = map { foo('inside', $_); foo('last', $_) } qw(alpha beta gam +ma);
Result:
foo(inside, alpha) called in void context
foo(last, alpha) called in list context
foo(inside, beta) called in void context
foo(last, beta) called in list context
foo(inside, gamma) called in void context
foo(last, gamma) called in list context

Context propagation from the caller to the internal statements only happens on the last statement (for each flow), or in explicit return calls.

Replies are listed 'Best First'.
Re: Re: Re: deprecated split ??
by diotalevi (Canon) on May 27, 2004 at 22:03 UTC
    split was the only expression in the block. The semicolon you thought was the statement separator was written inside the parentheses delimiting the arguments given to it.
      Hmm, you're right. That's probably why it doesn't compile, like plenty of other people replied.

      Without the parens, it works as predicted.