From ed198c5d218e80743815c46704d3d244573b7a63 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Tue, 9 Jul 2013 09:58:18 +0200 Subject: [PATCH] ulog_parser.pl: quote "-" values. Ungly but it works. --- ulog_parser.pl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ulog_parser.pl b/ulog_parser.pl index e4c04941..5b848e77 100755 --- a/ulog_parser.pl +++ b/ulog_parser.pl @@ -7,6 +7,7 @@ use YAML; use File::Spec; use Cwd 'abs_path'; use Data::Dumper; +use Tie::File; my $filename = "/var/log/ngcp/kamailio-proxy.log"; my $output_dir = "log"; @@ -33,6 +34,14 @@ sub save_data $path = File::Spec->catfile( $output_dir, (sprintf "%04i", $data->{'msgid'}).".yml"); YAML::DumpFile($path, $data); #print "$data->{'msgid'} saved\n"; + # This tries to fix problems with string values '-' being saved + # without quotes. + tie my @array, 'Tie::File', $path or die ('Can not open $path'); + for (@array) + { + s/(.*\$\w+\(\w+\):) -/$1 '-'/g + } + untie @array; } $data = { msgid => '',