in reply to Help with a regex

You understood ^ and $ correctly, you probably test it wrong. Could you give us the code sample that makes you reach that conclusion ?

perl -E 'say /^lib/ ? "$_ matched" : "$_ did not match" for qw/nfcclib lib/;'

nfcclib did not match lib matched

Alternatively, you could also use \b which means word boundary (so the regex m<\blib>; or its equivalent /\blib/)