in reply to searching using a scalar as pattern

To be safe of certain chars in $name, I'd rather use something like:
my @matched_lines = grep { /\Q$name/ } @lines;
Otherwise, if there is a / in $name, a syntax error might appear...

Best regards,
perl -e "print a|r,p|d=>b|p=>chr 3**2 .7=>t and t"