Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: The error says the value is uninitialized, but it works anyway

by karlgoethebier (Abbot)
on Aug 19, 2019 at 18:44 UTC ( #11104698=note: print w/replies, xml ) Need Help??

in reply to The error says the value is uninitialized, but it works anyway

A different solution AKA TMTOWTDI using Set::Scalar:

#!/usr/bin/env perl use strict; use warnings; use Test::More; use Data::Dump; use Set::Scalar; my @colors = qw(red green blue yellow pink purple brown); my @drop = qw(pink brown); my @expected = qw(red green blue yellow purple); my $colors = Set::Scalar->new(@colors); print qq(\@colors = ); dd @colors; print qq(\@drop = ); dd @drop; print qq(\@expected = ); dd @expected; $colors->delete(@drop); my @result = $colors->members; print qq(\@result = ); dd @result; is(@result, @expected, qq(Dropping members @drop from \@colors)); done_testing(); print qq(\@colors = ); dd @colors; __END__ Karls-Mac-mini:Desktop karl$ ./ @colors = ("red", "green", "blue", "yellow", "pink", "purple", "brown" +) @drop = ("pink", "brown") @expected = ("red", "green", "blue", "yellow", "purple") @result = ("purple", "red", "yellow", "green", "blue") ok 1 - Dropping members pink brown from @colors 1..1 @colors = ("red", "green", "blue", "yellow", "pink", "purple", "brown" +)

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11104698]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2020-09-24 18:49 GMT
Find Nodes?
    Voting Booth?
    If at first I don’t succeed, I …

    Results (135 votes). Check out past polls.