in reply to Re: Trying to make a search
in thread Trying to make a search

Grep is not obscure. It is much clearer than dumb loops that are really just low level implementations of list operations.
#!/usr/bin/perl -w use strict; print "Letter? "; chomp(my $letter = <STDIN>); open DATA, "books.txt" or die "open(books.txt) returned: $!\n"; print grep {/^$letter/io} <DATA>;
Of course, I kind of like something like
perl -e 'print grep {/^a/io} <>' /usr/dict/words
Try it, you'll like it too!