Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
So, in answer to question 1: no, it contains a reference (which might be an address of something, but you don't {and shouldn't} need to know what).

Got it. Thanks for that clarification!

$ in Perl as a sigil means "give me a scalar value". In answer to 2: $$ means give me the scalar referred to by the scalar xxx. Because you can assign values to a scalar when you use $$ in an assignment you are assigning to the scalar referred to by the scalar. No pointers to be seen here.

Ok, I think I understand what you are saying. Taking your explanation one step further, I was wondering if I could use a "triple dollar sign" ($$$). Not that this would be idiomatic or anything but apparently you can:

my $variable = 22; my $pointer = \$variable; say "The address of \$variable, which contains the value $variable,"; say "is $pointer"; $$pointer = 25; say "Look at that! \$variable now equals $variable"; my $double_pointer = \$pointer; $$$double_pointer = 50; say "Look at that! \$variable now equals $variable";
which results in
The address of $variable, which contains the value 22, is SCALAR(0x801e64540) Look at that! $variable now equals 25 $double_pointer = REF(0x801e644b0) Look at that! $variable now equals 50
...Perl doesn't need "output parameters" because it can return multiple values from a sub.

I didn't know that! That is very cool!

References in Perl are most useful in building interesting structures which are a mixture of arrays, hashes and scalar values.

I guess I just need to keep re-reading the excellent documentation and trying this out. I implicitly understand the power of references but still struggling with applying them.


In reply to Re^2: Pointers and References by Leudwinus
in thread Pointers and References by Leudwinus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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 or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2021-06-13 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (54 votes). Check out past polls.

    Notices?