in reply to Re: removing an element without index
in thread removing an element without index

That is a little more succinct as:

my @data = (1,2,3,4,5,6,7,8,9,10); @data = grep {! m/4/} @data; # Remove elements containing the digit 4
True laziness is hard work

Replies are listed 'Best First'.
Re^3: removing an element without index
by BrowserUk (Patriarch) on Aug 10, 2010 at 01:01 UTC

    This would be as succinct, more accurate, and a bit faster:

    @data = grep $_ ne '4', @data; # Remove elements equal to '4'

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      BrowserUk:

      It's not equivalent, though. I don't know if it would suit Levex's requirements or not, but it would give different results than the parent post if 14 or "BA4" were in the list of data.

      ...roboticus

        It's not equivalent, it would give different results than the parent post if 14 or "BA4" were in the list of data.

        Deliberately so. Hence "more accurate". I see nothing in the OPs post suggesting he wanted to remove multiple similar items; just one item.