![]() |
|
Welcome to the Monastery | |
PerlMonks |
Filter output based on valuesby LexPl (Sexton) |
on Nov 18, 2024 at 17:24 UTC ( [id://11162791]=perlquestion: print w/replies, xml ) | Need Help?? |
LexPl has asked for the wisdom of the Perl Monks concerning the following question: I have got a large number of specific regexes - stored in an array @regexes. My aim is to get a statistics which tells me what regexes occur in the input file and how often each one occurs. A count loop accumulates the number of occurrences for each $regex from the @regexes in a variable $tally.
Later I have an output loop that prints each $regex and its number of occurrences ($tally[i]).
Now I would like to exclude any regex from the output, which doesn't occur in my file ($tally[i] ne '0'). But my idea to wrap the printf statement in an if-statement doesn't work.
Please bear with me when I add a little secondary problem to this ticket. How could I describe the output format in printf so that all occurrences will be aligned properly independent from the length of the regex string?
Back to
Seekers of Perl Wisdom
|
|