#!perl -w use strict; my $padding = 0; for (){ chomp; $padding = $padding > length($_) ? $padding : length($_); } print "X" x $padding, "\n"; __DATA__ This is my file it doesn't have a blank line at the end of it based on the maxline count of the file that it read.