Skip to content

Instantly share code, notes, and snippets.

@jacoby
Created August 31, 2018 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacoby/9ce7cda85c8e1d0e0099199a831eecaa to your computer and use it in GitHub Desktop.
Save jacoby/9ce7cda85c8e1d0e0099199a831eecaa to your computer and use it in GitHub Desktop.
command line program that takes a regex and return what it matches
#!/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