http://www.perlmonks.org?node_id=1075044


in reply to I think regex Should Help Here... but How!?

As you're only trying to match the beginning of a string with no wildcards using index seems like a simpler approach.

foreach (@items) { say "$_ match" if index($_,$master) == 0; }

Replies are listed 'Best First'.
Re^2: I think regex Should Help Here... but How!?
by AnomalousMonk (Archbishop) on Feb 15, 2014 at 13:00 UTC

    This from ozboomer's OP

    if ($str =~ /^$buf/i) { ... }
    indicates a case-insensitive match is required, so index would not be appropriate.