package Iotta::Input::Header;
use strict;
require Iotta::Elem;
our @ISA = ("Iotta::Elem");
sub trim {
my $i = shift;
$i =~ s/^[ \t\n]+//;
$i =~ s/[ \t\n]+$//;
return $i;
}
sub run {
my $self = shift;
my $m = shift;
my $d = shift;
my @topics;
/()/;
$d =~ s/^title:(.*?)\n//;
$$m{title} = &trim ($1);
$d =~ s/^topic:(.*?)\n//;
@topics = split /,/, $1;
@topics = map { &trim ($_) } @topics;
push @topics, "unsorted" unless (scalar @topics);
@topics = sort @topics;
$$m{topics} = \@topics;
$d =~ s/^format:(.*?)\n//;
$$m{format} = &trim ($1);
$d =~ s/^\n//;
#$$m{name} = $name; # FIXME
unless ($$m{title}) {
my $title = $$m{name};
$title =~ s!^./.*?/!!; # FIXME?
$title =~ s!/!-!g;
$$m{title} = $title;
}
$self->next->run ($m, $d) if ($self->next);
return 0;
}
sub initialize {
my $self = shift;
$self->SUPER::initialize (@_);
}
1;
Platon Group <platon@platon.sk> http://platon.sk/
|