--- Andre` Niel Cameron <[EMAIL PROTECTED]> wrote: > Hi, > > I have a prob:) I need to search threw an array and remove an item based on > its name. I was thinking about maybie a for each loop but I am not sure how > to go about it. Heres what I need to do: > > say $object= sword; > I have an array @AllObjects('beer', 'nuts', 'sword', 'and more stuff') > Now sword may or may not ever be in the same location of the array so a > simple shift will not work here. I need to find a way to pull sword out of > that array. Any help is as always greatly appreciated:) > > > Regards, > Andre` C. > Technical Support > ԿԬ
@AllObjects = grep { $_ ne 'sword' } @AllObjects; Or, if you're not sure about the case: @AllObjects = grep { $_ !~ /^sword$/i } @AllObjects; See 'perldoc -f grep' Cheers, Curtis "Ovid" Poe ===== Senior Programmer Onsite! Technology (http://www.onsitetech.com/) "Ovid" on http://www.perlmonks.org/ __________________________________________________ Do You Yahoo!? Check out Yahoo! Shopping and Yahoo! Auctions for all of your unique holiday gifts! Buy at http://shopping.yahoo.com or bid at http://auctions.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]