Skip to content
Snippets Groups Projects
Commit a13fa8a4 authored by Robert Anderson's avatar Robert Anderson
Browse files

Added function for fetching queries

parent c4f6382d
No related branches found
No related tags found
No related merge requests found
...@@ -61,21 +61,18 @@ sub templateReplace ...@@ -61,21 +61,18 @@ sub templateReplace
my ($string,$hashref) = @_; my ($string,$hashref) = @_;
# Loop with hash sections my @valueArray = ();
foreach my $section (keys %{$hashref}) {
# Loop with section items
foreach my $item (keys %{$hashref->{$section}}) {
# Grab value
my $itemVal = $hashref->{$section}->{$item};
# Replace in string
$string =~ s/\%{$section\.$item(=[^}]+)?}/$itemVal/gi;
}
}
# Replace blanks # Replace blanks
$string =~ s/\%{[a-z]+\.[a-z0-9\-]+(?:=([^}]+))?}/$1/gi; while (my ($entireMacro,$section,$item,$default) = ($string =~ /(\%{([a-z]+)\.([a-z0-9\-]+)(?:=([^}]+))?})/i )) {
# Replace macro with ?
$string =~ s/$entireMacro/\?/;
# Add value onto our array
push(@valueArray,$hashref->{$section}->{$item});
}
return $string; return ($string, @valueArray);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment