perl-pe one-liner to inject single quotes

perl -pe ‘s/;\s*/;/g; s/(\d+)=(.*);/_$1=”$2″, /; s/\n//g;’ pspc_ms-pt_from_carbon.tmpl | perl -pe “s/\”/’/g”

In this solution, I break the task into two steps connected by pipe — more manageable.

  1. First step inserts double-quotes;
  2. Second step transforms all double quotes to single quotes.

I didn’t find a cleaner alternative.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s