Hello everyone, It has been awhile since I have used Perl, therefore I have lost some of my knowledge since I am not using it as often. I am trying to capture a line after skipping a variable of characters and whitespaces, my $find is at column 32 and I want to copy from there and there after for each line that matches my $find. I believe I as missing something or have something in the wrong place as the code works but I get zero results back. Thank you in advance.
use strict; my $find = '^(H0|HT)'; open (NEW, ">", "OUTPUT.txt" ) or die "could not open:$!"; open (FILE, "<", "INPUT.txt") or die "could not open:$!"; while (<FILE>) { print NEW if /^(.{32}$find)/; } close (FILE); close (NEW);
------------------- INPUT FILE: JANE, DOE HT000000000 123 50 70 80 JOHN, DOE JR H0000000000 123 50 70 80 WILLIAM, DOE HT000000000 123 50 70 80 ------------------- EXPECTED OUTPUT FILE: HT000000000 123 50 70 80 H0000000000 123 50 70 80 HT000000000 123 50 70 80
In reply to Copy Line After Skipping Columns by jlope043
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |