in reply to Apply regex to entire file, not just individual lines ?

Remember that if the unwanted stuff appears more than one per line you'll need a /g to match globally. $lines =~s/^unwantedstuff//gsm