Skip to content

Instantly share code, notes, and snippets.

@dex4er
Last active April 3, 2024 08:13
Show Gist options
  • Save dex4er/1330416 to your computer and use it in GitHub Desktop.
Save dex4er/1330416 to your computer and use it in GitHub Desktop.
Perl oneliners
# Perl 2 JSON
perl -MJSON -ple '$_=encode_json eval $_'
# JSON 2 Perl
perl -MJSON::PP -MJSON::Syck=Load -MData::Dumper -ple '$_=Dumper(Load(encode_json(JSON::PP->new->relaxed->allow_barekey->decode($_))));'
# MD5 checksum (whole file)
perl -MDigest::Perl::MD5=md5_hex -le 'undef $/; $_=<STDIN>; print md5_hex($_)'
# URL encoding by RFC 3986 (by line)
perl -MURI::Escape -ple '$_=uri_escape($_)'
perl -MURI::Escape -ple '$_=uri_unescape($_)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment