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

use strict;
use DBI;

use Fcntl qw(:seek); 

my $DSN = "dbi:mysql:dbname=poesis:host=localhost";

my $user = "razvan";
my $pass = "password";
my $dbh;
my $sth;


my ($IP, $title, $status);

my @linkuri;	# tabloul cu linkurile gasite

my @unique_links; # tabloul cu linkurile unice gasite

my $bigstring = "";
my $begintitle;

#my @lines = <>;

my $i = 0;

sub uniq {
	my %seen;
	return grep { !$seen{$_} ++ } @_;
}

open RESULT,  "<ip-index-html" or die "Connot open ip-index-html file: $!";

while(<RESULT>){
	if($i == 0){
		$IP = $_;
	}elsif($i == 1){
		$status = $_;
	}elsif($status =~ /200 OK/){
		if(/<title>/i && !defined($begintitle)){
			$begintitle = 1;
			if(/<\/title/i){
				($title) = /<title>([^>]+)<\/title>/i;
				if(defined($title)){
					$title =~ s/"/\\\"/g;	# put a backslash in front of "
					$title =~ s/'/\\\'/g;	# ... and '
					$title =~ s/^\s*//;	# discard heading spaces
					$title =~ s/\s*$//;	# discard trailing spaces 
				}
				last;
			}else{
				chomp;
				$bigstring .= $_;
			}
		}elsif(defined($begintitle)){
			if(/<\/title>/i){
				chomp;
				$bigstring .= $_;
				last;
			}else{
				chomp;
				$bigstring .= $_;
			}
		}
	}
	$i++;
}

if(!defined($title)){
	($title) = ($bigstring =~ /<title>(.+)<\/title>/i);
	if(defined($title)){
		$title =~ s/"/\\\"/g;
		$title =~ s/'/\\\'/g;
		$title =~ s/^\s*//;	
		$title =~ s/\s*$//;
	}
}

if(defined($title)){
	print "THREAD 1: IP = $IP";<commit_msg>Switched to Perl 5 style pattern matching in start-of-string and end-of-string anchors<commit_after>#!/usr/bin/perl -w

use strict;
use DBI;

use Fcntl qw(:seek); 

my $DSN = "dbi:mysql:dbname=poesis:host=localhost";

my $user = "razvan";
my $pass = "password";
my $dbh;
my $sth;


my ($IP, $title, $status);

my @linkuri;	# tabloul cu linkurile gasite

my @unique_links; # tabloul cu linkurile unice gasite

my $bigstring = "";
my $begintitle;

#my @lines = <>;

my $i = 0;

sub uniq {
	my %seen;
	return grep { !$seen{$_} ++ } @_;
}

open RESULT,  "<ip-index-html" or die "Connot open ip-index-html file: $!";

while(<RESULT>){
	if($i == 0){
		$IP = $_;
	}elsif($i == 1){
		$status = $_;
	}elsif($status =~ /200 OK/){
		if(/<title>/i && !defined($begintitle)){
			$begintitle = 1;
			if(/<\/title/i){
				($title) = /<title>([^>]+)<\/title>/i;
				if(defined($title)){
					$title =~ s/"/\\\"/g;	# put a backslash in front of "
					$title =~ s/'/\\\'/g;	# ... and '
					$title =~ s/\A\s*//;	# discard heading spaces
					$title =~ s/\s*\z//;	# discard trailing spaces 
				}
				last;
			}else{
				chomp;
				$bigstring .= $_;
			}
		}elsif(defined($begintitle)){
			if(/<\/title>/i){
				chomp;
				$bigstring .= $_;
				last;
			}else{
				chomp;
				$bigstring .= $_;
			}
		}
	}
	$i++;
}

if(!defined($title)){
	($title) = ($bigstring =~ /<title>(.+)<\/title>/i);
	if(defined($title)){
		$title =~ s/"/\\\"/g;
		$title =~ s/'/\\\'/g;
		$title =~ s/\A\s*//;	
		$title =~ s/\s*\z//;
	}
}

if(defined($title)){
	print "THREAD 1: IP = $IP";
{'fraction_non_alphanumeric': 0.25290408230999006, 'fraction_numerical': 0.005642217059409226, 'mean_word_length': 2.657766990291262, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, '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': '615132', 'n_tokens_mistral': 1508, 'n_tokens_neox': 1318, 'n_words': 280}