in reply to Re^4: Recomendations For Learning perl?
in thread Recomendations For Learning perl?

Command line one-liner:

perl -wMstrict -E 'print for grep /adam/, <>' /usr/share/dict/words

Script form (overly verbose so it's easier to understand):

use warnings; use strict; my $word_file = '/usr/share/dict/words'; open my $fh, '<', $word_file or die "can't open the $word_file file!: $!"; while (my $line = <$fh>){ if ($line =~ /adam/){ print $line; } }

Replies are listed 'Best First'.
Re^6: Recomendations For Learning perl?
by Laurent_R (Canon) on Dec 07, 2016 at 22:14 UTC
    Hi Steve,

    ++ for the code, but I don't think that you program will produce a list anywhere near the one by 1nickt, since your code looks for the adam letters in sequence.

      Yeah, I knew Nick would come back with some code as well, so I thought I'd put something out there that the OP could glean in the meantime ;)