in reply to Why won't $' work in a trinary operation?
If all you're using it for is to control execution (make one assignment versus another), use a normal if/else construct:
Arguably using /^#(.*)/ and $1 instead of $' is going to be a bit more efficient. Generally it's best to shy away from $` and $', as these add costly operations to an otherwise straightforward regex match.if ($base_string =~ /^#/) { $foo = $'; } else { $bar = $base_string; }
|
|---|