If you are going to return a hash reference from extract_episode_data() ...
sub extract_show_info {
my $input_string = shift();
my $result = undef;
if ( $result = extract_episode_data($input_string) ) {
$result->{type} = 'se';
} elsif ( my @date = $_ =~ /$RE{time}{ymd}{-keep}/ ) {
$result = { ... };
}
return $result;
}
sub extract_episode_data {
my $input_string = shift();
if ( ... )
{
my $episode_data = { season => $1, episode => $2 };
return $episode_data;
} else {
return;
}
}
... why not set the type in there too? That would lead to something like ...
sub extract_show_info {
my $input_string = shift @_;
my $result = extract_episode_data($input_string);
$result and return $result;
if ( my @date = $_ =~ /$RE{time}{ymd}{-keep}/ ) {
return { ... };
}
return;
}
sub extract_episode_data {
my $input_string = shift @_;
if ( ... ) {
return { type => 'se',
season => $1,
episode => $2
};
}
return;
}