chinamox has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to set up a little application to search a file and return only the words that have the letters "a b o r t" in alphabetical order. I think I have managed to use .*? to get rid of any characters between these letters but now I am returning words that don't even have all of the letters in them. I know that the fix is likely very short but this is only my second week working in Perl, and I haven't been able to suss it out so far.
Thank you for any help,#!/usr/local/bin/perl -w use strict; # seed files for <> operator @ARGV = qw( /usr/dict/words ); while (<>) { # look for b e n(regardless of intervening characters) print if /a.*?b.*?o.*?r.*?t/; };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regular expression questions
by imp (Priest) on Oct 07, 2006 at 14:33 UTC | |
by chinamox (Scribe) on Oct 07, 2006 at 20:28 UTC | |
|
Re: Regular expression questions
by prasadbabu (Prior) on Oct 07, 2006 at 14:30 UTC | |
by chinamox (Scribe) on Oct 07, 2006 at 14:43 UTC | |
|
Re: Regular expression questions
by jkeenan1 (Deacon) on Oct 07, 2006 at 14:43 UTC |