use PPI; # Load a perl document my $Document = PPI::Document->load( 'mycode.pl' ); my $significant = grep { ! $_->significant } $Document->tokens;