<commit_before>package Integration::Task::InplaceEdit;

use strict;
use warnings;

use Integration::Task;
our @ISA = qw(Integration::Task);

{

my %Edits_of;

sub new {
  my ($class, %params) = @_;
  my $self = $class->SUPER::new(%params);
  $Edits_of{$self} = [];
  return $self;
}

sub process {
  ### Performs an in place edit on a file defined by {{source}}. The resulting, edited file is placed in {{destination}}. Edits to make can be added as key value pairs using {{add_edit}}.
  my $self = shift;
  open (INPUT, $self->source) or die;
  my @lines = <INPUT>;
  my @update = ();
  close INPUT;
  foreach my $edit_array (@{ $self->edits }) {
    my $search = $edit_array->[0];
    my $replace = $edit_array->[1];
    open (OUTPUT, ">", $self->destination);
    my $count = 0;
    foreach my $line (@lines) {
      my $print = $line; 
      chomp $print;
      if ($print eq $search) {
        $print = $replace;<commit_msg>Updated inplace editing task with regexp searching.<commit_after>package Integration::Task::InplaceEdit;

use strict;
use warnings;

use Integration::Task;
our @ISA = qw(Integration::Task);

{

my %Edits_of;

sub new {
  my ($class, %params) = @_;
  my $self = $class->SUPER::new(%params);
  $Edits_of{$self} = [];
  return $self;
}

sub process {
  ### Performs an in place edit on a file defined by {{source}}. The resulting, edited file is placed in {{destination}}. Edits to make can be added as key value pairs using {{add_edit}}.
  my $self = shift;
  open (INPUT, $self->source) or die;
  my @lines = <INPUT>;
  my @update = ();
  close INPUT;
  warn "INPLACE EDIT!";
  foreach my $edit_array (@{ $self->edits }) {
    my $search = $edit_array->[0];
    my $replace = $edit_array->[1];
    warn "SEARCH: " . $search;
    warn "REPLACE: " . $replace;
    open (OUTPUT, ">", $self->destination);
    my $count = 0;
    foreach my $line (@lines) {
      my $print = $line; 
      chomp $print;
      if ($print =~ /$search/) {
        $print =~ s/$search/$replace/g;
{'fraction_non_alphanumeric': 0.16808404202101052, 'fraction_numerical': 0.0030015007503751876, 'mean_word_length': 3.329004329004329, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '977961', 'n_tokens_mistral': 698, 'n_tokens_neox': 680, 'n_words': 219}