in reply to Trying to make a search

As long as we're going for perl looking, we might as well go for obscure...
#/usr/bin/perl -w use strict; print "Letter: "; chomp(my $letter = <STDIN>); open(DATA, "books.txt") || die "error opening file $!"; while(<DATA>) { (/^$letter/i) && print; }

Replies are listed 'Best First'.
RE: Re: Trying to make a search
by turnstep (Parson) on Jun 04, 2000 at 17:57 UTC

    Please, before posting, read the guidelines and use a </{0,1}CODE> tags around your code, or else it will look like the above, which is not valid perl. For those curious, the poster meant for a <STDIN> to appear in the "chomp" line, and the while line to say while(<DATA>) {

    P.S. I think that

    print if /$letter/i;
    is shorter and a bit clearer.