Skip to content

Instantly share code, notes, and snippets.

@kylebgorman
Created March 19, 2020 21:33
Show Gist options
  • Select an option

  • Save kylebgorman/1b2e5a2d2d5abe12e50c7b5772985460 to your computer and use it in GitHub Desktop.

Select an option

Save kylebgorman/1b2e5a2d2d5abe12e50c7b5772985460 to your computer and use it in GitHub Desktop.

Revisions

  1. kylebgorman created this gist Mar 19, 2020.
    18 changes: 18 additions & 0 deletions 95to27.pl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/usr/bin/perl

    use strict;
    use warnings;

    use open ":encoding(ascii)";
    binmode STDIN, ":encoding(ascii)";
    binmode STDOUT, ":encoding(ascii)";
    binmode STDERR, ":encoding(ascii)";

    while (<>) {
    $_ = uc; # Case-folds.
    s/'//g; # Removes /'/ (right quotes and apostrophe).
    s/[\d\p{PosixPunct}]/ /g; # Replaces digits and punctuation with space.
    s/\s+/ /g; # Maps whitespace spans to a single / /s.
    s/^\s+|\s+$//g; # Removes edge whitespace.
    print "$_\n";
    }