I'm looking for an easy way to overwrite the empty string in a variable.
For undefined variables, I use the following:
$var //= '?';Which means (to me at least), "If $var is undef, then assign it the value '?'".
I would like something similar for the case when $var contains '', e.g.
$var ///= '';where I fabricated the '///=' operator for the purposes of illustration.
Currently, I use the following syntax:
$var = '?' if $var eq '';Can anyone think of a tighter syntax? The above approach becomes cumbersome as variable names increase in length. (Hmm, as I write this, I'm considering that perhaps long variable names are the root cause of this issue. I do a lot of coding around SNMP, and so end up with extravaganzas like $dot3adAggPortActorOperState_before and dot3adAggPortActorOperState_after.)
Anyway, I'm wanting a clear way to represent the process of overwriting the empty string in variables -- if you have suggestions, plse let me know.--sk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |