diff options
| author | LapVeesh <rabbiveesh@gmail.com> | 2019-04-21 11:11:48 +0300 |
|---|---|---|
| committer | LapVeesh <rabbiveesh@gmail.com> | 2019-04-21 11:11:48 +0300 |
| commit | bc48f4a394d64745da87660004d7ec6e67e7b4e1 (patch) | |
| tree | 95eb5364f097a97ba1925f486863cd81a692bbb3 /challenge-004 | |
| parent | 2fe3ee92c9aeabfe53a38f6a7e7b97151e7f4e24 (diff) | |
| download | perlweeklychallenge-club-bc48f4a394d64745da87660004d7ec6e67e7b4e1.tar.gz perlweeklychallenge-club-bc48f4a394d64745da87660004d7ec6e67e7b4e1.tar.bz2 perlweeklychallenge-club-bc48f4a394d64745da87660004d7ec6e67e7b4e1.zip | |
Added simple answer to advanced challenge
Diffstat (limited to 'challenge-004')
| -rwxr-xr-x | challenge-004/veesh-goldman/perl5/ch-02.pl | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/challenge-004/veesh-goldman/perl5/ch-02.pl b/challenge-004/veesh-goldman/perl5/ch-02.pl new file mode 100755 index 0000000000..9a5fdefee6 --- /dev/null +++ b/challenge-004/veesh-goldman/perl5/ch-02.pl @@ -0,0 +1,27 @@ +#! /usr/bin/perl + +my $usage = <<"EOF"; +USAGE: +$0 letters [file] + + letters - a string consisting of the letters to filter by + file - the name of a file to check for words. If ommited, checks STDIN + +$0 will search through the file for words that can be made from +the letters in the list argument. Each letter will only be used once. +EOF + +die $usage unless @ARGV; + +my $list = shift; + +while (<>) { + #remove newline + chomp; + #copy the string to check for letters + my $string = $_; + #remove any letter in our list from the word + $string =~ s/$_// for split //, $list; + #if there's no word left, then print our original word + CORE::say unless $string; +} |
