$_ = "http://this.is.a.very.long.url.and.this.is/very/bad?after=I&dont=like&long&urls=and&they=look&really=ugly"; print "before: $_\n"; s/(.{30}).*(.{20})/$1 ... $2/; print "after: $_\n";