#!/usr/bin/perl use strict; use warnings; my $line ="A\tB\tC\tD\t\t\t\t\n"; print "Test string line: $line"; print "Split without chomp: "; count_fields( $line ); print "Split _after_ chomp: "; chomp $line; count_fields( $line ); exit; sub count_fields { my ($line) = @_; my @x = split( /\t/, $line); my $count = @x; print "$count fields.\n"; }