The test for empty line has nothing to do with removing comments, so there's no need to check for it in the sub. I'd reverse the test and do away with the next:
sub RemoveComments
{
my $line=$_[0];
$$line =~ s/#.*$//; # No need for a separate pattern match
}
....
while ($temp=<INPUT>){
RemoveComments(\$temp);
if ($temp =~ /\S/){
...
some other code
...
}
}
but you could also do
while ($temp=<INPUT>){
RemoveComments(\$temp);
next if ($temp !~ /\S/);
...
some other code
...
}
Caution: Contents may have been coded under pressure.