Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@schwern
Created September 23, 2011 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schwern/1237023 to your computer and use it in GitHub Desktop.
Save schwern/1237023 to your computer and use it in GitHub Desktop.
my $tmpl1
= $file->{file_name} =~ /\.(avi|divx|mkv|flv|mp4|wmv)$/i
? 'download1_video.html'
: $file->{file_name} =~ /\.mp3$/i ? 'download1_audio.html'
: 'download1.html'
;
# or
my $video_re = qr{\. (avi|divx|mkv|flv|mp4|wmv) $}xi;
my $tmpl1
= $file->{file_name} =~ $video_re ? 'download1_video.html'
: $file->{file_name} =~ /\.mp3$/i ? 'download1_audio.html'
: 'download1.html'
;
# or
my $name = $file->{file_name};
my $tmpl1
= $name =~ /\.(avi|divx|mkv|flv|mp4|wmv)$/i ? 'download1_video.html'
: $name =~ /\.mp3$/i ? 'download1_audio.html'
: 'download1.html'
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment