From d64ba2f2b031b504cc90609f372daac0eefb88fe Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Sat, 2 Jul 2016 20:44:19 +1000 Subject: [PATCH] * Subtitle::SSA::Style : fix to_string() --- lib/Subtitle/SSA/Record.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Subtitle/SSA/Record.pm b/lib/Subtitle/SSA/Record.pm index 8fd8e74..138aa4d 100644 --- a/lib/Subtitle/SSA/Record.pm +++ b/lib/Subtitle/SSA/Record.pm @@ -95,9 +95,9 @@ sub parse { sub to_string { my ($self) = @_; - my $string = $self->{_prefix} . ' '; + my $string = $self->{_prefix} . ': '; my @values = (); - foreach my $field (@{ $self->{_fields} }) { + foreach my $field (@{ $self->{_format} }) { my $d = $self->{_fields}->{$field}; my $v = $self->{$field} // $d->{value}; if ($d->{type} eq 'x' and $self->{_vers} eq 'ass') { @@ -105,7 +105,7 @@ sub to_string { } elsif ($d->{type} eq 'f') { $v = sprintf "%.2f", $v; # hack: make decimal from float if fractional part is zero after round up - $v =~ s{\.00$}{}oi; + $v =~ s{[\.]?0*$}{}oi; } elsif ($d->{type} eq 'z') { $v = sprintf "%04d", $v; } elsif ($d->{type} eq 't') {