<commit_before>#!/usr/bin/perl -w

use lib '.';
use strict;
use warnings;
use DSL;

my $file;
my $dsl=DSL->new;
my $debug;

while(@ARGV and $ARGV[0] =~ /^-/) {
  my $opt=shift;
  if ($opt eq '-h') {
    usage();
  }
  elsif ($opt eq '-d') {
    $debug=1;
  }
  else {
    die "$0: ${opt}: unknown option\n";
  }
}

usage("no files to run") unless (@ARGV);

for $file (@ARGV) {
  print "=== $file\n" if (@ARGV>1);
  open(FILE, '<', $file) or die "$0: ${file}: unable to open file for reading\n";
  my $script=do { local $/; <FILE> };
  close(FILE);
  my $parsed_script=$dsl->parse($script);
  die "$0: ${file}: parsing failed\n" unless (defined($parsed_script));
  print $parsed_script->do;
}

sub usage {
  print STDERR "$0: usage: $0 [files...]\n";
  if (@_) {
    print STDERR map { "$_\n" } (@_);
    exit 1;
  }
  exit 0;
}
<commit_msg>clean up for perlcritic<commit_after>#!/usr/bin/perl -w

use lib '.';
use strict;
use warnings;
use DSL;

my $file;
my $dsl=DSL->new;
my $debug;

while(@ARGV and $ARGV[0] =~ /^-/) {
  my $opt=shift;
  if ($opt eq '-h') {
    usage();
  }
  elsif ($opt eq '-d') {
    $debug=1;
  }
  else {
    die "$0: ${opt}: unknown option\n";
  }
}

usage("no files to run") unless (@ARGV);

for my $file (@ARGV) {
  print "=== $file\n" if (@ARGV>1);
  open(my $fh, '<', $file) or die "$0: ${file}: unable to open file for reading\n";
  my $script=do { local $/; <$fh> };
  close($fh);
  my $parsed_script=$dsl->parse($script);
  die "$0: ${file}: parsing failed\n" unless (defined($parsed_script));
  print $parsed_script->do;
}

sub usage {
  print STDERR "$0: usage: $0 [files...]\n";
  if (@_) {
    print STDERR map { "$_\n" } (@_);
    exit 1;
  }
  exit 0;
}

{'fraction_non_alphanumeric': 0.2297696396928529, 'fraction_numerical': 0.011813349084465446, 'mean_word_length': 3.0526315789473686, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1936502', 'n_tokens_mistral': 718, 'n_tokens_neox': 709, 'n_words': 195}