in reply to Re: Why do I (sometimes) get a REF ref and not a SCALAR ref?
in thread Why do I (sometimes) get a REF ref and not a SCALAR ref?

Thanks very much to all responders. Now it makes sense. Somehow I was thinking $x = \$x took a reference to the value in $x, not $x itself. And yes, $a and $b were ill-chosen.

The code that gave rise to this was creating a PPI::Document. This takes as its first argument either a file name or a scalar reference to the literal code to be analyzed. I wanted my wrapper to treat its argument as a file if it represented an extant file, otherwise as literal code. My code started out PPI::Document->new( -e $arg ? $arg : \$arg ), which worked fine. Then as the code became more complex I decided I wanted to move the test elsewhere, which gave rise to -e $arg and $arg = \$arg;. The final iteration of the relevant code was -e $arg and $arg = \( my $temp = $arg );