Hi all, let's consider
I'd like to have a function that does this :my $current_yummy_cake = "apple pie"
To avoid having to type this all the time:say_var($current_yummy_cake); # prints : $current_yummy_cake = >apple pie<
say "$current_yummy_cake= >" . $current_yummy_cake . "<";
It doesn't seem simple: the say_var() subroutine needs to retrieve the name of a variable which is declared in the scope just above. Is this possible ?
I am aware that there are other solutions such as
- having a shortcut in my (Vim) editor, to type this line for me.
=> I'd like to avoid ending up with hundreds of shortcuts.
- having a subroutine that takes the name of the variable, and the variable itself.
=> It'd be nice to avoid the redundancy.
If it's not achievable, no worries (^c^)
In reply to How to retrieve the name of a variable ? by mascip
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |