in reply to searching for clear ways to overwrite the empty string
The empty string is one of the false values, so if your string can't be another false value (eg: "0"), $var ||= "?" will work (you'll have to use the // version first if you want a different behavior for undefined and false).
The for keyword can also be used as an aliasing mechanism for your long name problem:
$_ eq '' and $_ = '?' for $yourVariableWithAVeryLongName;
This has the added benefit of making it easier to apply the same modification to several variables:
$_ //= '?' for ($yourFirstVariableWithAVeryLongName, $yourSecondVariableWithAVeryLongName, $IShouldHaveUsedCopyPasteInsteadOfTyping);
|
|---|