in reply to pattern matching

Two things...
push my @users, $line;
Is better written as either:
push my(@users), $line;
OR
my @users; push @users, $line;
But your error is being caused because split using the default value in $_ instead of $line. Instead try:
split(/ /,$line)

-Blake

Replies are listed 'Best First'.
Re: Re: pattern matching
by runrig (Abbot) on Sep 06, 2001 at 22:39 UTC
    >> 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.
      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

Re: Re: pattern matching
by softworkz (Monk) on Sep 06, 2001 at 22:18 UTC
    Thanks! That was the problem :( walks away with his head down with embaressment.