use strict; use warnings; use Test::More tests => 43; use Subtitle::Format::SSA::Header; my $sample = <<"EOF"; [Script Info] ; Script generated by Aegisub 2.1.9 ; http://www.aegisub.org/ Title: Some title ScriptType: v4.00+ WrapStyle: 0 PlayResX: 1280 PlayResY: 720 ScaledBorderAndShadow: yes Video Aspect Ratio: 0 Video Zoom: 4 Video Position: 11787 Original Translation: Some author Original Editing: Some corrector Collisions: Normal Last Style Storage: Some style Audio File: ?video EOF my @headers; my @lines = split /\n/, $sample; splice @lines, 0, 3; # skip section header and comments foreach my $line (@lines) { my $header = Subtitle::Format::SSA::Header->new; ok($header->parse($line), "line parsing"); my ($name, $value) = split(": ", $line, 2); is($header->{name} => $name); is($header->{value} => $value); my $key = $header->hash_key(); push @headers, $header; } $sample = <<"EOF"; Title: Some title ScriptType: v4.00+ WrapStyle: 0 PlayResX: 1280 PlayResY: 720 ScaledBorderAndShadow: yes Video Aspect Ratio: 0 Video Zoom: 4 Video Position: 11787 Original Translation: Some author Original Editing: Some corrector Collisions: Normal Last Style Storage: Some style Audio File: ?video EOF @lines = (); foreach my $h (@headers) { push @lines, $h->to_string(); } my $out = join("\n" => @lines) . "\n"; is($sample => $out); exit 0;