in reply to Re: scalar ref losing it's value?
in thread scalar ref losing it's value?

please educate me about the meaning of "reference"...isn't the entity "$UIDholder" the scalar reference to the value which in this case was an integer?? what's wrong about saying that the reference was printing in my incorrectly quoted code, when, in fact, it was the reference which was printing in my HTML??

i admit, i often have trouble with referencing and dereferencing, but it's getting better :-D

Replies are listed 'Best First'.
Re^3: scalar ref losing it's value?
by apprentice (Scribe) on May 05, 2006 at 14:49 UTC
    $UIDholder is just a variable name. If you want a reference to it, you do this:
    my $UIDholder = "some value"; my $var_ref = \$UIDholder; print "UIDHolder: $UIDholder\n"; print "reference: $var_ref\n";

    This gives the output:
    UIDholder: some value reference: SCALAR(0x8160e8c)

    Note that the memory location of your reference may be different from mine. SCALAR indicates the type of variable the reference points to.
    To use the reference, you have to 'dereference' it. For instance, to print the actual value the variable holds by using the reference instead of the variable name, throw an extra $ sign in front of the $var_ref variable name:
    print "Actual value of variable: $$var_ref\n";


    I hope this helps.


    "Peace, love, and Perl...well, okay, mostly just Perl!" --me

    Apprentice
      thank you - that does help (i knew the concept, i was just getting hung up on the words)...