TeamSite 5.5.2 on Windows.
I think this POD in WFtask.pm is inaccurate - it says it reutrns a hash ref (wouldn't that be nice) but it looks like it actually returns undef? I find that a really nice way of returning multiple values is to return a hash. For instance it would be nice if I could do:
my %{info} = ${task}->GetFilesAndComments();
if ( defined( ${info{'error'}} ))
{
die( ${info{'error'}} );
}
else
{
my ${data} = ${info{'files'}};
foreach my ${file} ( keys( %${data} ))
{
my ${comment} = $${data{${file}}};
}
}
Something like that anyway, my Perl skills are pretty poor but in general I find the less dereferencing the better.
=head2 GetFilesAndComments(\%f_and_c)
Returns a (possibly empty) hash ref with file names as the keys
and values are refs to an array of hash refs (see GetFileComments).
=cut
sub GetFilesAndComments
{
my ($this, $f_and_c) =
@_;
$this->GetXML();
if (!$this->{xml_valid})
{
$this->{error_string} = 'GetFiles failed: invalid workflow xml';
return ();
}
my $felements = TeamSite::WFutils::find_element($this->{xml}[1], 'files');
if (!$felements)
{
return ();
}
my %files;
my
@file_element_list;
TeamSite::WFutils::find_element_list($felements, 'file', \
@file_element_list);
for my $felement (
@file_element_list) {
my $path = $felement->[0]{path};
my
@file_comments;
$this->GetFileComments(\
@file_comments, $felement);
$f_and_c->{"$path"} = \
@file_comments;
}
return undef;
}