use strict; use warnings; use Test::More tests => 3; my @strings = ( 'Now is the time', '"Now is the time"', "'Now is the time'", ); my $regex = qr/^['"]?(.*?)['"]?$/; for my $input (@strings) { my ($match) = ($input =~ /$regex/); is $match, 'Now is the time', "$input matched"; }