Using just one Perl substitute or matching regular expression statement , how can we modify below code:
I need to modify the value of $pattern<
You can use the perl special variable @LAST_MATCH_START to get the output:
use strict; use warnings; my $pattern = "F1"; my $string = "F1234F12F1F1234F12F13"; my $count; while ( $string =~ /$pattern/g ) { $count++ if $-[0] % 5 == 0; } print $count;
4