This occurs for the same reasons given above as
\"foo";
creates a references to a constant value whereas
\"foo$x";
is creating a reference to a temporary value.
If you want to see the evidence then just put Devel::Peek to work (take note of the FLAGS values for the reference):
use Devel::Peek;
my $x = 'foo';
Dump \'foo';
Dump \"bar$x";
__output__
SV = RV(0x183c90c) at 0x225fe4
REFCNT = 1
FLAGS = (PADBUSY,PADTMP,ROK,READONLY)
RV = 0x225ffc
SV = PV(0x22626c) at 0x225ffc
REFCNT = 1
FLAGS = (POK,READONLY,pPOK)
PV = 0x1831d04 "foo"\0
CUR = 3
LEN = 4
SV = RV(0x183c92c) at 0x2252ac
REFCNT = 1
FLAGS = (TEMP,ROK)
RV = 0x225150
SV = PV(0x2261a0) at 0x225150
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x1831cac "barfoo"\0
CUR = 6
LEN = 7
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|