in reply to Print string next to pattern matching?
Try this
The regex match should match anything after the colon and by using $1 uses that match. Use your own file names also.
#!/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.
In Section
Seekers of Perl Wisdom