You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package Subtitle::SSA::Header;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use utf8;
|
|
|
|
|
|
|
|
use overload
|
|
|
|
'""' => \&to_string,
|
|
|
|
;
|
|
|
|
|
|
|
|
sub new {
|
|
|
|
my ($class) = @_;
|
|
|
|
my $self = {
|
|
|
|
name => undef,
|
|
|
|
value => '',
|
|
|
|
};
|
|
|
|
return bless($self, $class);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub hash_key {
|
|
|
|
my ($self) = @_;
|
|
|
|
my $key = lc($self->{name});
|
|
|
|
$key =~ s{\s+}{}go;
|
|
|
|
return $key;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub parse {
|
|
|
|
my ($self, $line) = @_;
|
|
|
|
|
|
|
|
return unless $line;
|
|
|
|
return if $line =~ m{^ \s* ;}xo; # comment
|
|
|
|
|
|
|
|
chomp $line;
|
|
|
|
$line =~ s{^\s+}{}o;
|
|
|
|
$line =~ s{\s+$}{}o;
|
|
|
|
my ($name, $value) = split /\s*:\s*/, $line, 2;
|
|
|
|
|
|
|
|
$self->{name} = $name;
|
|
|
|
$self->{value} = $value;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub to_string {
|
|
|
|
my ($self) = @_;
|
|
|
|
|
|
|
|
return $self->{name} . ': ' . $self->{value};
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|