Not sure what your input file looks like, as you only give one 'field'. However, assuming it's like the __DATA__ below (even with varying whitespace), you could do something like this:
use strict; use warnings; my $to_find = 'Pretty Woman'; while ( <DATA> ) { if ( /$to_find:\s*(\d+)/ ) { print "Slot for $to_find: $1\n"; } } __DATA__ Label Location Start Time End Time NKL0289 MSL6000 Trinity: 7 18:45 20:45 NKL0111 MSL7000 A Fish Called Wanda: 22 11:11 13:00 XKL0ABCC MSL8000 Pretty Woman: 55 18:13 20:12
dave
In reply to Re: Extract field after keyword
by Not_a_Number
in thread Extract field after keyword
by jamen_98
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |