I call <this> a macro in my text file.
I need to find all matches to a regex and put each match from a single scalar, into one or more positions in an array. I'm trying to pull out strings that look like /<(ig|igt|igo|igxo);.+?>/. Basically I need to pull out macros that begin with "<ig;", "<igt;", "<igo;", "<igxo;" and end with ">".
This is my attempt.
my($re,$lin,@g,@inarr);
my(@inarr)=(
'stuff{tag}<igo;123>stuff<ig;abc>',
'<igt;ddd>stuff blah {foo}',
'stuff blah foo <igxo;dsldkd.eps>',
'<igt;aaa>stuff blah <igx;hhh>'
);
$re='<(ig|igt|igo|igxo);.+?>';
foreach $lin (@inarr)
{
@g=($lin=~m/$re/g);
} # foreach
After this runs on $inarr[0], @g should contain:
@g=('<igo;123>',
'<ig;abc>'
);
but I'm getting:
@g=('ig');
What am I doing wrong here? I've already searched Google but haven't found what I'm looking for yet.
Thank you.