Loading ...
Sorry, an error occurred while loading the content.

RE: [PBML] Grep - removing multiple array elements

Expand Messages
  • Charles K. Clarkson
    ... Character classes match single characters, not words. use Data::Dumper Dumper ; my @lines = ( p1 , , Yes , p2 , No , Help! , N/A ); my @remove =
    Message 1 of 2 , Aug 2, 2006
    View Source
    • 0 Attachment
      hooyar66 wrote:

      : @line = grep !/[@remove]/, @line;

      Character classes match single characters, not words.


      use Data::Dumper 'Dumper';

      my @lines = ('p1', ' ', 'Yes', 'p2', 'No', 'Help!', 'N/A');

      my @remove = ('Yes', 'No', 'N/A');

      my $regex = join '|', @remove;

      @lines = grep !/$regex/, @lines;

      print Dumper \@lines;


      HTH,

      Charles K. Clarkson
      --
      Mobile Homes Specialist
      Free Market Advocate
      Web Programmer

      254 968-8328

      Don't tread on my bandwidth. Trim your posts.
    Your message has been successfully submitted and would be delivered to recipients shortly.