in reply to Matching a truncated word
perl -le '$x = shift; print 1 if $x and "foobar" =~ /^\Q$x/'
update: added a first test to stop empty $x's from matching (thanks Sifmole), and a \Q in the regex as per the Perl Cookbook. Also note that in Real Life I would of course say 'foobar' and not "foobar", but that's neither here nor there.
--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Matching a truncated word
by Sifmole (Chaplain) on Jul 31, 2001 at 21:40 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |