#!/usr/bin/perl -wp # Print all lines before the first one that matches the pattern, inclusive. # Does a case-insensitive match. # The pattern is the first argument. # All other arguments are treated as files to read; if none are supplied, # standard input is read. # Output goes to standard output. # (This should probably be implemented as an option to the "lines-before" # script, rather than being its own script.) BEGIN { $pattern = shift @ARGV; } if (/$pattern/io) { print; exit; }