in reply to Default value for capture in regular expression
I wouldn't do that with a (single) regex at all. There are tons of other ways: in particular in this case your data seems fairly regular. Thus one possibility (and just one amongst the may WTDI) may be:
my %defult = (what => 'wtf?', date => 'no date', data => 'no data'); # ... unless (exists $default{$data}) { warn "unexpected field: $data'"; # ... } $value ||= $default{$data};
Of course //= would be better suited for this, but since we currently don't have it yet unless we installed a patch, ||= should be enough. If it is not or in case of doubt, use your own defined test instead.
|
|---|