Created
August 31, 2018 20:51
-
-
Save jacoby/9ce7cda85c8e1d0e0099199a831eecaa to your computer and use it in GitHub Desktop.
command line program that takes a regex and return what it matches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict ; | |
use warnings ; | |
use utf8 ; | |
use feature qw{ postderef say signatures state } ; | |
no warnings qw{ experimental::postderef experimental::signatures } ; | |
use Getopt::Long ; | |
my $regex ; | |
GetOptions( | |
'regex=s' => \$regex | |
); | |
exit unless defined $regex; | |
my @output; | |
while (<STDIN>) { | |
push @output , $_ =~ m{$regex}gmix; | |
} | |
say join "\n", @output; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment