5
Debconf::Format::822 - RFC-822-ish output format
9
package Debconf::Format::822;
11
use base 'Debconf::Format';
15
This formats data in a vaguely RFC-822-ish way.
27
# Make sure it's sane.
40
while ($line = <$fh>) {
42
last if $line eq ''; # blank line is our record delimiter
48
my ($var, $value)=split(/\s*=\s?/, $line, 2);
50
$ret{variables}->{$var}=$value;
58
# Process the main structure.
59
my ($key, $value)=split(/:\s?/, $line, 2);
61
if ($key eq 'owners') {
62
foreach my $owner (split(/,\s+/, $value)) {
63
$ret{owners}->{$owner}=1;
66
elsif ($key eq 'flags') {
67
foreach my $flag (split(/,\s+/, $value)) {
68
$ret{flags}->{$flag}='true';
71
elsif ($key eq 'variables') {
74
elsif ($key eq 'name') {
79
$ret{fields}->{$key}=$value;
83
return unless defined $name;
93
print $fh "Name: $name\n" or return undef;
94
foreach my $field (sort keys %{$data{fields}}) {
95
my $val=$data{fields}->{$field};
97
print $fh ucfirst($field).": $val\n" or return undef;
99
if (keys %{$data{owners}}) {
100
print $fh "Owners: ".join(", ", sort keys(%{$data{owners}}))."\n"
103
if (grep { $data{flags}->{$_} eq 'true' } keys %{$data{flags}}) {
104
print $fh "Flags: ".join(", ",
105
grep { $data{flags}->{$_} eq 'true' }
106
sort keys(%{$data{flags}}))."\n"
109
if (keys %{$data{variables}}) {
110
print $fh "Variables:\n" or return undef;
111
foreach my $var (sort keys %{$data{variables}}) {
112
my $val=$data{variables}->{$var};
114
print $fh " $var = $val\n" or return undef;
117
print $fh "\n" or return undef; # end of record delimiter
123
Joey Hess <joeyh@debian.org>