We don't bite newbies here... much | |
PerlMonks |
Re: Question on File Handler and Subroutines in Perlby thanos1983 (Parson) |
on Mar 05, 2019 at 09:43 UTC ( [id://1230889]=note: print w/replies, xml ) | Need Help?? |
Hello Anonymous Monk, Perl is a well known scripting language that people choose to create 'Modules' that can assist you / us to reduce our lines of code to minimum. For example reading and loading all lines of a file in an array while removing the new line characters all in one line :) One of the modules that I usually prefer to use is IO::All. Then your task is simplified you just need to set the pattern to match (string or even multiple strings) and grep all elements that match your pattern using grep as you have done already :). Small sample of code bellow:
You need to adjust it to your preferences but it should be close to what you want to achieve. Update: I do not want to include the solution with the subroutine. There are several ways to put all your data together. One possible way I would suggest push. Give it a try and we will help you more if you get problems. After all programming / scripting is all about trying and failing until you get it right :) Hope this helps, BR.
Seeking for Perl wisdom...on the process of learning...not there...yet!
In Section
Seekers of Perl Wisdom
|
|