in reply to Re^2: The error says the value is uninitialized, but it works anyway
in thread The error says the value is uninitialized, but it works anyway
"...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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: The error says the value is uninitialized, but it works anyway
by AnomalousMonk (Archbishop) on Aug 18, 2019 at 21:22 UTC |
In Section
Seekers of Perl Wisdom