in reply to A fast way to do this?

Shell + Perl solution:
#!/bin/sh INFILE=test.in # get number of lines not matching "^#" (-v inverses the results) non_comment_lines=$(cat $INFILE | grep -cv "^#"); if [ 0 -lt $non_comment_lines ]; then perl ./process_file.pl < $INFILE fi
For a Perl-only solution, slurp in the file contents and use a regex:
#!/usr/bin/env perl use strict; use warnings; $/=undef; open my $fh, "<", "test.in"; my $file = <$fh>; if ($file =~ m/^#/) { print "process me!\n"; }