You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

28 lines
712 B

#!/usr/bin/env perl
use warnings;
use strict;
use 5.10.0;
# Quote a pattern to match:
# - /x means "extended syntax" - can include whitespace and comments
# - /i means "case insensitive"
# - qr is a quote operator - quotes everything between the delimiters
# as a regular expression
my $pattern = qr/
^ # Start
( \d{4}-\d{2}-\d{2} ) # Date
.* # Everything else
$ # End of line
/xi;
# Loop over each line of:
# 1. standard input, if given
# OR
# 2. the files given on the CLI
while (<>) {
# The line is now in $_, the default variable.
# Print the first capture group if we got a match:
say $1 if m/$pattern/;
}