I found this code to scan a file and print each occurrence of a string. As it is, the exact search string is printed. How can I print a different part of the line when the string is found?
Example: Search for "Name:", and every time it is found, print just the name itself (which falls one space after the colon) and not the search string "Name:".
use constant FILE => 'search.txt';
use constant FIND => 'string to find';
my $fh = IO::File->new(FILE, O_RDONLY)
or die 'Could not open file ', FILE, ": $!";
$fh->getline; #fast forward to the first match
#print each occurence in the file