in reply to check if all certain chars are found in a sentence
#!/usr/bin/perl use strict; use warnings; my $sentence = "abxcd zwe rrv"; my $wantedLetters = "tzxv"; my %required = map {$_ => 1} split //,$wantedLetters; map delete $required{$_}, split //, $sentence; if (keys %required) { print "required yet missing: ",keys %required,"\n"; } else { print "all requirements were met!\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: check if all certain chars are found in a sentence
by RMGir (Prior) on Aug 27, 2008 at 21:11 UTC |