in reply to reuse of split variable?

In each case, the computation on the right-hand-side of the '=' operator is completed in its entirety before it is assigned to @fields.

You can see a similar concept at work in this very common expression:

my $value = 10; $value = $value + 1; print $value, $/;

In this example, $value + 1 is evaluated first, and the result is assigned to $value


Dave

Replies are listed 'Best First'.
Re^2: reuse of split variable?
by Anonymous Monk on Nov 11, 2004 at 18:57 UTC

    Thank you for your answer.
    I'm used to C and sometimes you cannot work on a variable space ans storing results to it at the same time.

    Advantages of Perl
      True in perl also, but only in nooks and crannies. Compare these three:
      $ perl -we'@foo = 1..10; for (@foo) { delete $foo[10-$_] } print scala +r @foo' 5 $ perl -we'@foo = 1..10; for (my @bar=@foo) { delete $foo[10-$_] } pri +nt scalar @foo' 0 $ perl -we'@foo = 1..10; for (@foo,()) { delete $foo[10-$_] } print sc +alar @foo' Use of freed value in iteration at -e line 1.

        Very interesting ....

        Did you know where to look for this kinds of things?
        Where are they documented?
        Apart from www.perlmonks.com of course

        Thanks, as we say is Spain (proverb), "you'll never go to sleep without knowing something new".
        I've discovered what a nook and a crannie are