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.
--In reply to Re: Matching a truncated word
by grinder
in thread Matching a truncated word
by John M. Dlugosz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |