@kyanny's blog

My thoughts, my life. Views/opinions are my own.

these_keys what_keys 決定版

function these_keys() {
  cat - | perl -Xsnle 'BEGIN{ @keys = split / +/, $keys; $, = " " } %tmp = /([^ ]+)=("[^"]+"|[^ ]+)/g; for $key (@keys) { push @tmp, "$key=$tmp{$key}" }; print @tmp; undef @tmp' -- -keys="$*"
}

function what_keys() {
  cat - | perl -Xnle 'BEGIN { $, = "\n" } @tmp=/([^ ]+)=/g; for $key (@tmp) { push @keys, $key unless $key ~~ @keys }; END{ print @keys}'
}