in reply to piggy back infos on a string scalar
Use object overloading.
Ties and Variable::Magic (which was mentioned elsewhere in the thread) attach to the variable, not to the value, like this:
my $x = "Hello world"; attach_some_special_magic( $x ); my $y = $x; # $y has no special magic
As you're passing the string around, you don't want that. You want an overloaded object.
The danger with overloaded objects is that the third-party module you mention might check !ref( $str ) to ensure it's been passed a string. If it's doing that, you still have one workaround. Bless the object into a package called "0". Then ref( $str ) will return "0" which is false.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: piggy back infos on a string scalar
by LanX (Saint) on Feb 24, 2023 at 16:30 UTC | |
by tobyink (Canon) on Feb 24, 2023 at 21:37 UTC | |
by LanX (Saint) on Feb 24, 2023 at 23:17 UTC |