[Israel.pm] Doing it the perlish way

Yossi.Itzkovich at ecitele.com Yossi.Itzkovich at ecitele.com
Thu Jun 8 11:06:15 PDT 2006


Hi,

I have this simple script, that acts as interactive grep on /usr/dict/words file.  Is there more "perlish" way to write it ?

Thanks



#! /usr/local/bin/perl -w
my $dict="/usr/dict/words";
open (DICT,$dict) or die "can't open $dict";
my @dict=<DICT>;
while (<STDIN>)
  {
    chomp ( my $pat=$_);
    $pat eq "END" and exit;
    print "pat=$pat.\n";
    print ( join ("," ,grep ({ /$pat/} @dict)),"\n");
  }




More information about the Perl mailing list