On Tue, 24 Sep 2002, David Samuelsson (PAC) wrote:

> @array = grep !/^\s*$/, @array;
> This will return an array of elements (removing all elements that are either filled 
>with spaces or are blank)
> 
> George.
> 
> i read that it wasnt so good to use this in ther perlfaq:

There is nothing wrong in using grep or map if you want to process all the 
elements in the array. 
It is ineffecient if you are performing a first match kind of operation. 
In your original post you did not have a last statement in the for loop, 
leading us to believe that you are processing all the elements in the 
array. 

For your problem it is better to use a hash instead with the usernames as 
keys. To remove a users information delete that key (perldoc -f delete)

> 
> Please do not use
> 
>     ($is_there) = grep $_ eq $whatever, @array;
> or worse yet
> 
>     ($is_there) = grep /$whatever/, @array;
> These are slow (checks every element even if the first matches), inefficient (same 
>reason), and potentially buggy 
> (what if there are regex characters in $whatever?).

To get around this place $whatever in between a \Q and a \E in the 
pattern. (perldoc perlre)


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to