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.
In reply to Re: Function for reading file
by hippo
in thread Function for reading file
by shabird
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |