in reply to deprecated split ??

There is a typo in your code. You put a semi-colon after the /;\s*/ but should have a comma instead. You also wrote $_[1] which ... I would *guess* should probably be $_->[1]. The way you've written this function and it has been interpreted is a model of obfuscation. split() called like this is in list context (contrary to someone else's assertion that it is scalar) and shouldn't pull up that warning. That perl has somehow decided to treat it as void context means that split separates the first element of the @_ array, then writes into it. The next call then splits the previous call's output and so on.

Perhaps you mean @models = map { ( split /;\s*/ )[ 1 ] } @models which is significantly more probable.

Replies are listed 'Best First'.
Re: Re: deprecated split ??
by bart (Canon) on May 27, 2004 at 20:53 UTC
    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.

      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.