in reply to Matching a truncated word

I think that in this case the best approach uses substr:

my $matched = do { my $i = length $_; $_ eq substr "foobar",0,$i; };
or alternatively
my $matched = ($_ eq substr "foobar",0,length);
(if we're going to use special variables, may as well do it right...)

The idea is from the CB discussion that led to <plug type="shameless">this snippet </plug>, which seems to work--I am hopeful therefore that this will also work. :-)



If God had meant us to fly, he would *never* have given us the railroads.
    --Michael Flanders