"...We haven't learned "map" or "grep" yet..."
What does you discourage from reading the friendly manual and learning it by yourself?
Some sketch written in a hurry for your further inspiration:
#!/usr/bin/env perl use strict; use warnings; use Test::More; use Data::Dump; my @colors = qw(red green blue yellow pink purple brown); my @drop = qw(pink brown); my @expected = qw(red green blue yellow purple); my $regex = join "|", @drop; my @result = grep {!/$regex/} @colors; is($regex, q(pink|brown), q(Regex seems to be OK!)); is(@result, @expected, qq(Heureka!)); done_testing(); dd \@drop; dd $regex; dd \@colors; dd \@result; __END__
It's not carefully tested. And may be there is a better solution. Best regards, Karl
«The Crux of the Biscuit is the Apostrophe»
perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help
In reply to Re^3: The error says the value is uninitialized, but it works anyway
by karlgoethebier
in thread The error says the value is uninitialized, but it works anyway
by mizducky
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |