!/usr/bin/perl -l use strict; use warnings; sub foo { # ... $_ = undef; } while () { chomp; if (/^FOO/) { foo(); print "found $_"; } if (/^BAR/) { # ... print "found $_"; } # ... } __DATA__ FOO BAR