in reply to Pattern Match
Since you haven't said where the problem actually lies for you the specification is incomplete. Maybe a read of How to ask better questions using Test::More and sample data will help with that. However, it is pretty trivial to avoid the dotstar in this case.
#!/usr/bin/env perl use strict; use warnings; use Test::More; my @good = ( 'Fruits{ Apple Mango Grape Watermelon }', 'Fruit{ Apple }' ); my @bad = ( 'who', 'knows{ what }', 'you expect here' ); my $re = qr/^Fruits?{ [A-Za-z ]* }$/; plan tests => @good + @bad; for my $str (@good) { like ($str, $re, "$str matched"); } for my $str (@bad) { unlike ($str, $re, "$str not matched"); }
|
|---|