foreach $textline (@text){ #for everyline in the test file
$_ = $textline;
if(/(Position\:|Direct-Hire Position)\s+/g ... /\s+(.*\n.*)/g){
$result = $1;
chomp($result);
$result =~ s/\s+/ /g;
# return "$result "; next;
print OUTFILE1 "$result "; next;
}
I have the above in a subroutine. This prints from the first match to the second using range, since the match is on more than one line. I changed the print line to the return line because I wanted to run some checks on the matched value. So I have $var = &subroutine, run checks on $var, then I print $var to OUTFILE.
But I notice that the range no longer works as expected. Only the first match is printed to OUTFILE, the second is not there:
'Direct-Hire Position' is printed instead of 'Direct-Hire Position Communication Satellites/Space Experience Required - Ten or more years engineering experience.'
How can I get the entire match to print, without printing immediately? Can I assign the entire result of the range to a value that I can use later?
$_ = $textline;
if(/(Position\:|Direct-Hire Position)\s+/g ... /\s+(.*\n.*)/g){
$result = $1;
chomp($result);
$result =~ s/\s+/ /g;
# return "$result "; next;
print OUTFILE1 "$result "; next;
}
I have the above in a subroutine. This prints from the first match to the second using range, since the match is on more than one line. I changed the print line to the return line because I wanted to run some checks on the matched value. So I have $var = &subroutine, run checks on $var, then I print $var to OUTFILE.
But I notice that the range no longer works as expected. Only the first match is printed to OUTFILE, the second is not there:
'Direct-Hire Position' is printed instead of 'Direct-Hire Position Communication Satellites/Space Experience Required - Ten or more years engineering experience.'
How can I get the entire match to print, without printing immediately? Can I assign the entire result of the range to a value that I can use later?