in reply to Function for reading file
Your code as it stands isn't doing what you think because you open FH, but read from GB.
Regardless, if you do have $content correctly populated somehow then you can abstract the matching away to a subroutine like this:
my @matches = foo ($content); print "Data:@matches\n"; sub foo { return shift =~ /DATA\s+([A-Za-z\W]+)\n/g; }
See perlsub and our subroutine tutorials for further info.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Function for reading file
by shabird (Sexton) on Mar 25, 2020 at 09:54 UTC |