open( $l, "; close( $l ); foreach my $line ( @lines ) { # Skipping if the line is empty or a comment next if ( $line =~ /^\s*$/ ); next if ( $line =~ /^\s*#/ ); my ($firstname, $lastname, $age) = split( /\s+/, $line ); # then do whatever you have to }