in reply to Print string next to pattern matching?
#!/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; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Print string next to pattern matching?
by sumathigokul (Acolyte) on May 06, 2015 at 02:48 UTC |