# Read a text file, stripping leading and trailing whitespace
# and ignoring any lines starting with '#'
my $file = shift;
open(my $in, '<', $file) or die "error: open $file: $!";
my @lines = grep { s/^\s+//; s/#.*//; s/\s+$//; $_ } <$in>;
close($in);
for my $x (@lines) { print "x='$x'\n" }
####
my @lines = grep { s/^\s+//; s/#.*//; s/\s+$//; length($_) } <$in>;
####
my @lines = map { s/^\s+//; s/#.*//; s/\s+$//; length($_) ? $_ : () } <$in>;