http://qs321.pair.com?node_id=1125743


in reply to Print string next to pattern matching?

Try this

#!/usr/bin/perl use strict; use warnings; open FILE,"<file.txt"; my @array = <FILE>; close FILE; foreach(@array){ if(/^.+?:\s(.+)$/) { open NEW_FILE, ">>new_file.txt"; print NEW_FILE "$1\n"; close NEW_FILE; } }

The regex match should match anything after the colon and by using $1 uses that match. Use your own file names also.