Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^5: Recomendations For Learning perl?

by stevieb (Canon)
on Dec 07, 2016 at 22:01 UTC ( [id://1177438]=note: print w/replies, xml ) Need Help??


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 ;)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-25 03:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found