in reply to •Re: Elegant way to parse an optional prefix with default?
in thread Elegant way to parse an optional prefix with default?

Hmm, it looks like (with the parens, sorry about the typo) $1 is not undef but left to an old value if there is no match?!

So I do need to put something on the first line to test for success failure, at least. (or update the regex to make $1 success but blank)

My ugly one line is:

my $sigil= ($name =~ s/^([$@%&<*])//) ? $1 : '&';
as I couldn't get it to work with my ($sigil)= ... in list context to return matches. I guess that doesn't work with replacements as opposed to matches.

—John