Are you sure that your question is not an XY Problem?
Why do you construct your string in the first place while you can avoid parsing it back using regexes if you make a simple check, like this?
(read Conditional Operator if you don't know what <condition> ? <value> : <value> means)my $greet = $name ? $obj->{getName}->($name) : "<what you wanted to do + in case of (unknown)>";
In reply to Re: How to cater a self defined escape char in regex ?
by aitap
in thread How to cater a self defined escape char in regex ?
by exilepanda
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |