#!/usr/bin/perl use feature say; #undef $/; use POSIX qw(locale_h); setlocale(&POSIX::LC_ALL, "pt_PT"); use locale; my $file = shift; my $end = qr{ar|er|ir}; open(FILE, $file) or die("Can't open file $file.\n"); while(){ print $_ if (/$end\s?$/); }