while() { s/&/&/g; s//>/g; s!(https?://[-~@=_%;&/\+\.\?a-zA-Z0-9]+)!$1!g; s!([-_\+\.a-zA-Z0-9]+@[-_\+\.a-zA-Z0-9]+)!$1<\/a>!g; # then print $_, or whatever you want to do with it }