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

use JSON::PP;
use Data::Dumper;
use CGI qw();

my $c = CGI->new;
print "Content-type: text/plain\n\n";
if ('POST' eq $c->request_method ) {

	my $http      = $c->param("http");
	my $mongo     = $c->param("mongo");
	my $rabbit    = $c->param("rabbit");
	my $memcached = $c->param("memcached");

	my $harnessFile;
	open(my $fh, '<', "/var/www/html/harness.json");
	{
		local $/;
		$harnessFile = <$fh>;
	}
	close($fh);
	my $harness = decode_json $harnessFile;

	# Mongo
	my $mongouri = $$harness{"facilities"}{"storage"}{"mongoDB"}{"uris"}[0];
	$mongouri .= ":$mongo";
	$$harness{"facilities"}{"storage"}{"mongoDB"}{"uris"}[0] = $mongouri;

	# Memcached
	my $cacheuri = $$harness{"facilities"}{"cache"}{"memcached"}{"uris"}[0];
	$_ = $cacheuri;
	s/(.*\:)\d+/$1$memcached/;
	$$harness{"facilities"}{"cache"}{"memcached"}{"uris"}[0] = $_;

	# RabbitMQ
	$$harness{"facilities"}{"queue"}{"rabbitMQ"}{"port"} = $rabbit;

	# HTTP
	$$harness{"facilities"}{"http"}{"port"} = $http;

	my $jsonOut = encode_json (\%$harness);

	open(my $fh, '>', '/var/www/html/harness.json');
	print $fh $jsonOut;
	close $fh;
} else {
	print <<EndOfHTML;
<html><head><title>Perl Environment Variables</title></head>
<body>
<h1>Perl Environment Variables</h1><commit_msg>Add support for HTTPPORT<commit_after>#!/usr/bin/perl -wl

use JSON::PP;
use Data::Dumper;
use CGI qw();

my $c = CGI->new;
print "Content-type: text/plain\n\n";
if ('POST' eq $c->request_method ) {

	my $http      = $c->param("http");
	my $mongo     = $c->param("mongo");
	my $rabbit    = $c->param("rabbit");
	my $memcached = $c->param("memcached");

	my $harnessFile;
	open(my $fh, '<', "/var/www/html/harness.json");
	{
		local $/;
		$harnessFile = <$fh>;
	}
	close($fh);
	my $harness = decode_json $harnessFile;

	# Mongo
	my $mongouri = $$harness{"facilities"}{"storage"}{"mongoDB"}{"uris"}[0];
	$mongouri .= ":$mongo";
	$$harness{"facilities"}{"storage"}{"mongoDB"}{"uris"}[0] = $mongouri;

	# Memcached
	my $cacheuri = $$harness{"facilities"}{"cache"}{"memcached"}{"uris"}[0];
	$_ = $cacheuri;
	s/(.*\:)\d+/$1$memcached/;
	$$harness{"facilities"}{"cache"}{"memcached"}{"uris"}[0] = $_;

	# RabbitMQ
	$$harness{"facilities"}{"queue"}{"rabbitMQ"}{"port"} = $rabbit;

	# HTTP
	$$harness{"facilities"}{"http"}{"port"} = $http;

	my $jsonOut = encode_json (\%$harness);
	$jsonOut =~ s/HTTPPORT/$http/g;

	open(my $fh, '>', '/var/www/html/harness.json');
	print $fh $jsonOut;
	close $fh;
} else {
	print <<EndOfHTML;
<html><head><title>Perl Environment Variables</title></head>
<body>
<h1>Perl Environment Variables</h1>
{'fraction_non_alphanumeric': 0.2561538461538462, 'fraction_numerical': 0.005384615384615384, 'mean_word_length': 5.12, 'pattern_counts': {'":': 2, '<': 27, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '2042211', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1059, 'n_words': 178}