#!perl -i.bak my @input = <>; if (!scalar grep {/Friday/} @input) { splice @input, 1, 0, "Friday\n"; } print @input;