hostname3 # this is a comment for hostname3 #### Use of uninitialized value in substitution (s///) at ./comment line 11, line 1. #### #!/usr/bin/perl -w use strict; open(FH, "comments.txt") or die "cant open file"; while (my $line = ) { chomp $line; next if $line =~ /^$/; $line = s/\s*\#.*//; print "|$line|\n"; } close(FH);