Apparently, it's possible to store a "raw symbol" (as opposed to a reference to a symbol) in a scalar variable and use it in scalar contexts.
How do you determine whether a scalar-valued expression is one of these symbols?
They appear to stringify to "*name_of_symbol"
and ref
returns ""
. However Data::Dumper
is also able to determine that it isn't a string and prints it without quoting.
Is it possible to determine when you have a raw symbol? How is Data::Dumper
doing it?
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
local *foo = \4;
my $sym = *foo;
printf "((%s))\n", $sym;
printf "[[%s]]\n", (ref $sym);
print Dumper($sym);
produces:
((*main::foo))
[[]]
$VAR1 = *::foo;
I was expecting some dedicated value for ref $sym
.