This should work.
my $match_queue = qr{ QUEUE # literal word 'QUEUE' \( # literal open paren (.*?) # non-greedy capture of >=0 \) # literal close paren }xms; my $match_rname = qr{ RNAME # literal word 'RNAME' \( # literal open paren (.*?) # non-greedy capture of >=0 \) # literal close paren }xms; if ( $line =~ /AMQ8409/ ) { my ($queue) = ($line =~ $match_queue); my ($rname) = ($line =~ $match_rname); printf OUTPUT "QUEUE(%s) ------> RNAME(%s)\n", $queue, $rname; }
It could be quite a bit shorter, but I thought some /x clarity would be good.
In reply to Re: capturing words
by kyle
in thread capturing words
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |