This is another case where Perl probably is not the right tool for the job and you would be better off using sed than bringing up an entire perl instance just for one exact match. Try something like:
exec { "/bin/sed -i -e '\\%${line}%d' '${file}'" : ... }
Your problem seems to be the presence of the regex delimiter in some of the data that you need to match. Try using a different delimiter — in Perl /$pat/ is shorthand for m/$pat/ and you can replace it with m[$pat]. See perlsyn and perlop for more details.
In reply to Re: One liner: remove ssh keys with quotemeta
by jcb
in thread One liner: remove ssh keys with quotemeta
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |