#!/usr/bin/perl while (<>) { BEGIN { print "Hello\n"; } print $_; } Then print Hello as the first line of text in a file.