From e74302f560bdafe3c0801e89e105359cd9244948 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Thu, 30 Jun 2016 16:50:32 +1000 Subject: [PATCH] + Subtitle::SSA::Record->parse_format_line() --- lib/Subtitle/SSA/Record.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/Subtitle/SSA/Record.pm b/lib/Subtitle/SSA/Record.pm index b5f445f..cbdb051 100644 --- a/lib/Subtitle/SSA/Record.pm +++ b/lib/Subtitle/SSA/Record.pm @@ -53,6 +53,24 @@ sub set { return 1; } +sub parse_format_line { + my ($self, $line) = @_; + + return unless $line and $line =~ m{^Format:}oi; + + chomp $line; + $line =~ s{^Format:\s+}{}oi; + + my @fields; + foreach my $field (split(/,\s*/o, $line)) { + $field = lc($field); + return unless exists $FIELDS{$field}; + push @fields, $field; + } + + return [ @fields ]; +} + # formats: # s - string, use as is # d - decimal, no-zero pad