This works fine. The problem is that the following changes have been introduced and I'm not sure how to deal with them.use Data::Dumper; $Data::Dumper::Terse = $Data::Dumper::Indent = 1; my $test = <<EOT; opt = {word|word|word|word|word|word|word|word|word| word|word|word|word|word|word| word|word|word|word|word|word|word|word|word} logn = {alpha|<beta>|<gamma>} objn = {blah|blah|blah|blah|blah|blah|<blah>} set = [ one | two | three ] EOT my $delim = qr{\s*\|\s*}; my $box = qr/\w+\s*=\s*\[\s*([^]]+)\s*\]/; my $brace = qr/\w+\s*=\s*{\s*([^}]+)\s*}/; my $re = qr/^\s*$brace\s*$brace\s*$brace\s*$box\s*$/; if ($test =~ $re) { my ($opt, $set) = ($1, $4); my @opt = split $delim, $opt; my @set = split $delim, $set; print Dumper({ opt => [ @opt ], set => [ @set ] }), $/; }
Three changes have been introduced. A start line a finish line and the objn line now has braces in it as well. All I want is the contents of the lines beginning opt = and set = as before (as the example demonstrates).my $test = <<EOT; This is a new line [,set ] opt = {word|word|word|word|word|word|word|word|word| word|word|word|word|word|word| word|word|word|word|word|word|word|word|word} logn = {alpha|<beta>|<gamma>} objn = {blah|blah{blah|blah|blah}blah|<blah>} set = [ one | two | three ] (this is new also) EOT
In reply to metachar match by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |