in reply to Re: pattern matching
in thread pattern matching

>> push my(@users), $line; # or even more straightforward: my @users = ($line);
But I don't see the point of @users anyway. First, its misnamed. It doesn't really contain 'users', it contains data for one 'user'. You're setting it to '($line)' then resetting it on the very next line. If you really mean to collect 'users' in this array, then you wouldn't use my on the push statement, but you'd declare (my) '@users' in an outer block somewhere.

Replies are listed 'Best First'.
Re: Re: Re: pattern matching
by blakem (Monsignor) on Sep 06, 2001 at 22:52 UTC
    I guess you're right... If you're using my to declare it immediately beforehand, push is the same as assignment.

    I don't know the use for @users either, but the code snippet above is a non-balanced fragment:

    while(<FILE>) { my @users; [snip] if ( [snip] ) { [snip] } # @users is still in scope as we fall off the end....
    Therefore, perhaps there is a use for it outside of the window we've been shown.

    Looking at it a second time, @users should probably be scoped outside the while, since it is most-likely supposed to be an array of slightly munged lines from the file.

    -Blake