#!/usr/bin/perl use strict; use warnings; my $comment = join "", ; my %replaces = ( '/video.google.com/' => { name => 'Google-Video', from => qr'\/videoplay\?', to => q'/googleplayer.swf?' }, 'youtube.com/' => { name => 'Youtube', from => qr'\/watch\?v=', to => q'/v/' }, 'myvideo.de/' => { name => 'MyVideo', from => qr'\/watch\/(\d+)\/.+', to => q'/embed/$1' }, 'clipfish.de/' => { name => 'Clipfish', from => qr'\/video\/(\d+)\/.+', to => q'/embed_video/?vid=$1' }, # ); my $repl = sub { my $url = shift; my $template = shift; my $src; return if not length $url; for my $k ( keys %replaces ) { if ( $url =~ /$k/ ) { my $from = $replaces{ $k }->{ from }; my $to = $replaces{ $k }->{ to }; $src = $url if length $url and $url =~ /$from/; $url =~ s|$from|$to|e; $src = $url if not defined $src; $template =~ s|###NAME###|$replaces{$k}->{name}|g; $template =~ s|###URL###|$url|g; $template =~ s|###SRC###|$src|g; return $template; } } return qq{

Video von '$url' kann nicht eingebettet werden!

}; }; my $regex = qr|\]+)?\s*\>|; while ( $comment =~ $regex ) { $comment =~ s|$regex|$repl->($1,q{
Der Browser kann das Video nicht darstellen

Quelle: ###NAME### } )|egi; } print $comment; #### __DATA__ .