#!/usr/bin/perl # Usage: Apply the last line of the input as a Perl regex. my @lines = split "\r|\n",<>; my $regex = pop @lines; my $text = join "\n",@lines; chomp $regex; while (not $regex) { $regex = pop @lines; chomp $regex; } eval '$text =~ '.$regex; print $text;