in reply to capturing words

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.

Replies are listed 'Best First'.
Re^2: capturing words
by Anonymous Monk on Nov 08, 2007 at 16:13 UTC
    Thanks guys ,, that should help a lot