use strict; use warnings; use Test::More tests => 32; use Subtitle::SSA::Header; my (@lines, $header, $sample); $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 $header = Subtitle::SSA::Header->new(version => 'ssa'); @lines = split /\n/, $sample; diag scalar @lines; shift @lines; # skip header foreach my $line (@lines) { ok($header->parse($line), 'line parsing'); } is($header->get('ScriptType') => 'v4.00+'); is($header->get('Title') => 'Some title'); is($header->get('WrapStyle') => 0); is($header->get('PlayResX') => 1280); is($header->get('PlayResY') => 720); is($header->get('ScaledBorderAndShadow') => 'yes'); is($header->get('Video Aspect Ratio') => 0); is($header->get('Video Zoom') => 4); is($header->get('Video Position') => 11787); is($header->get('Original Translation') => 'Some author'); is($header->get('Original Editing') => 'Some corrector'); is($header->get('Collisions') => 'Normal'); is($header->get('Last Style Storage') => 'Some style'); is($header->get('Audio File') => '?video'); is($header->{_vers} => 'ass'); # changed with ScriptType $sample = <<"EOF"; [Script Info] ; generated with Subtitle::SSA ScriptType: v4.00+ Title: Some title 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 is($sample => $header->to_string()); use File::Slurp qw(write_file); write_file('a.txt', $sample); write_file('b.txt', $header->to_string()); exit 0;