my $filename = $ARGV[0]; open( FILE, "< $filename" ) or die "Can't open $filename : $!"; while( ) { s/#.*//; # ignore comments by erasing them next if /^(\s)*$/; # skip blank lines chomp; # remove trailing newline characters push @lines, $_; # push the data line onto the array } close FILE; print @lines;