in reply to Please review this: code to extract the season/episode or date from a TV show's title on a torrent site
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Please review this: code to extract the season/episode or date from a TV show's title on a torrent site
by Cody Fendant (Hermit) on Aug 18, 2016 at 09:34 UTC |