#!/usr/local/bin/perl
use strict;
use warnings;
my $match = qr{perl}i;
print "\n\n";
while ( <> ) {
chomp;
my @words = split /\s+/;
my $output = '';
foreach my $word ( @words ) {
if ( $word =~ m{http://} ) {
my $before = my $after = '';
if ( $word !~ m{^(:?http://|telnet://|ftp://|chrome://)} ) {
$word =~ s{^(.*?)(http://|telnet://|ftp://|chrome://)}{$2};
$before = $1;
}
if ( $word =~ m{[^\w\d/]+$} ) {
$word =~ s{([^\w\d/]+)$}{};
$after = $1;
}
my $str = '';
if ( $word =~ m{$match} ) {
$word =~ s{($match)}{$1};
}
$str .= $word . '';
$word = $before . $str . $after;
} elsif ( $word =~ m{$match} ) {
$word =~ s{($match)}{$1};
}
$output .= ' ' . $word;
}
print $output . "\n";
}
print "\n\n";