#!/usr/bin/perl -w use strict; open(R,"textfile"); my @F=; close(R); pop @F if (@F[scalar(@F)-1] eq "\n"); print @F;