I don't use puppet either. However, I do not see the point in using regex for this:
/usr/bin/perl -ni -e 'print unless /^\\Q${line}\\E\$/' '${file}'
where it appears that you are just wanting an exact match on the entire line. While quotemeta will get you so far, remember that you are substituting ${line} in at the shell level, so any regex-terminating characters within that variable will also have to be escaped somehow. Much better to use an exact match I would have thought.
Similarly, you could specify the line to remove in an env var, thus avoiding one layer of escaping.
Without puppet and just using STDIN for clarity, here is a demo of both:
$ export LINE=bar $ echo -e "foo\nbar\nbaz" | perl -lne 'print unless $_ eq $ENV{LINE}'
You'll still need to sanitize/escape/quote your equivalent of "bar" when setting the environment variable but that should be a simpler task.
In reply to Re: One liner: remove ssh keys with quotemeta
by hippo
in thread One liner: remove ssh keys with quotemeta
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |