Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Please review this: code to extract the season/episode or date from a TV show's title on a torrent site

by Anonymous Monk
on Aug 18, 2016 at 08:09 UTC ( [id://1169976]=note: print w/replies, xml ) Need Help??


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; }
  • Comment on Re: Please review this: code to extract the season/episode or date from a TV show's title on a torrent site
  • Select or Download Code

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
    ... why not set the type in there too?

    Makes sense, but I was trying to keep the two completely separate, de-coupled or whatever the right word is. Then I can re-use the season-episode sub cleanly for something else? Maybe I'm over-thinking.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1169976]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-18 12:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found