#!/usr/bin/perl use strict; my $output = ""; open(FILE, "file.txt") || die "$!"; while() { $output .= $_; } close FILE; $output =~ s#(http://[^\!\"\£\$\^\*\(\)\{\}\[\]\;\:\'\@\,\<\> ]+)#\$1\#gis; print $output; #### The quick brown fox at http://fish.org would like to go home and http://see through.com/pants/foo/bar what there is to eat #### The quick brown fox at http://fish.org would like to go home and http://see through.com what there is to eat