Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^4: RFC: Tutorial: use strict; now what!?

by educated_foo (Vicar)
on Feb 09, 2012 at 15:06 UTC ( #952748=note: print w/replies, xml ) Need Help??


in reply to Re^3: RFC: Tutorial: use strict; now what!?
in thread RFC: Tutorial: use strict; now what!?

$foo = 23; $soft = 'foo'; # soft reference $hard = \$foo; # hard reference print "soft=$$soft, hard=$$hard\n";
A soft reference holds a variable's name, while a hard reference holds its memory address. When you dereference a soft reference, you search for a name in the symbol table. When you dereference a hard reference, you fetch the variable at that address.

Replies are listed 'Best First'.
Re^5: RFC: Tutorial: use strict; now what!?
by tangent (Priest) on Feb 09, 2012 at 16:52 UTC
    Thanks for explaining, I didn't know you could do that. BTW when I run that I get "soft=, hard=23"
      Are you running exactly that program? What version of Perl? This is what I get:
      $ cat foo2.pl $foo = 23; $soft = 'foo'; $hard = \$foo; print "soft=$$soft, hard=$$hard\n"; $ perl foo2.pl soft=23, hard=23 $ perl -v This is perl, v5.10.1 (*) built for i686-cygwin-thread-multi-64int
        I did change it slightly by adding my (couldn't help myself)
        user$ cat foo2.pl my $foo = 23; my $soft = 'foo'; # soft reference my $hard = \$foo; # hard reference print "soft=$$soft, hard=$$hard\n"; user$ perl foo2.pl soft=, hard=23 user$ perl -v This is perl 5, version 14, subversion 1 (v5.14.1) built for darwin-2level user$ cat foo3.pl $foo = 23; $soft = 'foo'; # soft reference $hard = \$foo; # hard reference print "soft=$$soft, hard=$$hard\n"; user$ perl foo3.pl soft=23, hard=23
        I think I've learnt something about 'my' too!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://952748]
help
Chatterbox?
[choroba]: just one of its angles, in fact
[LanX]: <|--
[choroba]: Reminds me of an old joke about an orchestra...
erix imagines that in a true Lancs accent
[choroba]: so a Czech orchestra rehearses a new piece by a German composer
LanX LOL of the day ... the Turkish Anonymous Alcoholics stopped their "No to alcohol" campaign for political reasons ...
LanX omg my browser is posting again on its own ...
[LanX]: choroba: GREAT JOKE! xD

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2017-03-27 11:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (319 votes). Check out past polls.