@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: 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?). //Dave -----Original Message----- From: George P. [mailto:[EMAIL PROTECTED]] Sent: den 24 september 2002 13:39 To: David Samuelsson (PAC) Cc: '[EMAIL PROTECTED]' Subject: Re: regexp hides info? On Tue, 24 Sep 2002, David Samuelsson (PAC) wrote: > I have an array with a lot of data. > > i want to remove certain elements from it: > so i ran: > for (@array){ > s/$current_user.*//; > } > > nw when i print it, all $current user are gone as i wanted, but its a big space in >the array instead. > like: > > user1 > user1 > user2 > user2 > > > > user4 > user4 > user4 > etc.. > > how do i get the array to be without the spaces, i tried to remove all whitespaces >with s/\s+/, that didnt seem to work, any ideas? > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]