Mercury,
I'm sorry but I don't have a lot of time to reply just now as my system seems to be gradually failing since a power cut borked something; now it can't even bring up a terminal session. I think a re-install may be in order.
Just a few of quick points:
- It is good practice for code maintenance to maintain a consistent indenting scheme so it might be an idea, having placed some of the code in a subroutine, to indent it further to aid legibility.
- Don't preface your subroutine calls with an ampersand (&). That has a specific meaning which, in general, you don't want, see perlsub.
- Now that you have employed a subroutine you will need it to return something and actually assign that to a variable, my $result = search_phrase( ... );
- To cope with numbers at the start of your line, and to cope with not finding the phrase, you will need to modify the line that starts with the print, perhaps changing to an if ( cond ) { ... } else { ... } and change the regular expression to cater for digits either at the beginning or the end. Hint: use the * quantifier (0 or more) rather than the + (1 or more).
I hope this short reply is enough to help you move forward. I hope my system lasts long enough for me to click the <create> button ;-)
Cheers,
JohnGG