From ec182cf8f7c33e0e10b8af4eb62543457cf22bc0 Mon Sep 17 00:00:00 2001 From: Tomas Plesnik <plesnik@ics.muni.cz> Date: Fri, 4 Jul 2014 15:13:31 +0200 Subject: [PATCH] perlovy modul pro ziskavani struktur z konfiguracnich soouboru --- src/warden-server/sh/perlCommon.pm | 73 ++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 src/warden-server/sh/perlCommon.pm diff --git a/src/warden-server/sh/perlCommon.pm b/src/warden-server/sh/perlCommon.pm new file mode 100755 index 0000000..276afec --- /dev/null +++ b/src/warden-server/sh/perlCommon.pm @@ -0,0 +1,73 @@ +# perlCommon.pm +# +# Copyright (C) 2011-2014 Cesnet z.s.p.o +# +# Use of this source is governed by a BSD-style license, see LICENSE file. + +package perlCommon; + +use warnings; +use strict; + +################################################################################ +# VARIABLES +################################################################################ +our $VERSION = "2.2"; + +################################################################################ +# FUNCTIONS +################################################################################ +sub getConfHash { + my $arg = shift; + my $hash; + our %VALID_STRINGS; + require $arg; + while (my ($key, $value_ref) = each %VALID_STRINGS) { + $hash .= " \"$key\" => [\"$value_ref->[0]\""; + shift($value_ref); + foreach my $element (@$value_ref) { + $hash .= ", \"$element\""; + } + $hash .= "],\n"; + } + print $hash; +} + +sub getConfArrayPre { + my $arg = shift; + my $array; + our @SQL_PRECONDITION; + require $arg; + foreach my $element (@SQL_PRECONDITION) { + $array .= "'$element', "; + } + print $array; +} + +sub getConfArrayPost { + my $arg = shift; + my $array; + our @SQL_POSTCONDITION; + require $arg; + foreach my $element (@SQL_POSTCONDITION) { + $array .= "'$element', "; + } + print $array; +} + +sub getConfArrayQueries { + my $arg = shift; + my $array; + our @SQL_QUERIES; + require $arg; + foreach my $hash_ref (@SQL_QUERIES) { + $array .= "{"; + while (my ($key, $value_ref) = each $hash_ref) { + $array .= "$key => \"$value_ref\", "; + } + $array .= "},\n"; + } + print $array; +} + +1; -- GitLab