in reply to Printing the count for regex matches
Produces this result:#!/usr/bin/perl use strict; use warnings; while (<DATA>) { my $string_found = $_; my @match = ( $string_found =~ /(first_string|second_string|third_stri +ng|fourth_string|fifth_string)/gm ); print scalar @match," matches found: ",join ", ",@match, "\n"; } __DATA__ This is a test file matchme ljldjlfjd l;djfldjlf d test test test dljfldjlfjldjfldjlljdf one second_string dlfjldfj ljdfldjjf ldjfljdl dfljdlfj dfdlfj three ljfldjlj dlfjlasdj foiidufoiida matchdf dljfldsaofuoidfousdaof ladsjflasdof first_string dlfjodsuofuasdo sadoufosadu foasduf aosduf third_string
3 matches found: second_string, first_string, third_string,
|
|---|