open( my $FH, "<", $fileOrPipeOrWhatever ) or die $!; my $fileSize = 0; while( my $line = <$FH> ) { $fileSize += length($line); } # while close( $FH );