I have been playing around with a RE that is supposed to extract the value of a tag.
The program below already does the right thing, but I have an undefined feeling that it could be done with some kind of alternation aka |. But I can't get it to do what I want. I have been reading the docs but either the info is too thin or my head is too thick.
So I was wondering if someone can show me how alternation can/should be used.
TIA#!perl -w use strict; while( <DATA> ) { chomp; my ( $data ) = m/TAG:\"([^\"]+)\"/ ? $1 : m/TAG:([^\"\s]+)/ ? $1 : + 'not_def'; print "$_ => $data\n"; } __DATA__ TAG:"test of data" TAG:test_of_data TAG:test of data TAG: test TAG:test of data" TAG:"test of data TAG:test-2_3.we
In reply to Alternation in pattern matches by guha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |