Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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

by tangent (Priest)
on Feb 09, 2012 at 16:52 UTC ( #952784=note: print w/replies, xml ) Need Help??

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

Thanks for explaining, I didn't know you could do that. BTW when I run that I get "soft=, hard=23"
  • Comment on Re^5: RFC: Tutorial: use strict; now what!?

Replies are listed 'Best First'.
Re^6: RFC: Tutorial: use strict; now what!?
by educated_foo (Vicar) on Feb 09, 2012 at 17:10 UTC
    Are you running exactly that program? What version of Perl? This is what I get:
    $ cat $foo = 23; $soft = 'foo'; $hard = \$foo; print "soft=$$soft, hard=$$hard\n"; $ perl 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 my $foo = 23; my $soft = 'foo'; # soft reference my $hard = \$foo; # hard reference print "soft=$$soft, hard=$$hard\n"; user$ perl soft=, hard=23 user$ perl -v This is perl 5, version 14, subversion 1 (v5.14.1) built for darwin-2level user$ cat $foo = 23; $soft = 'foo'; # soft reference $hard = \$foo; # hard reference print "soft=$$soft, hard=$$hard\n"; user$ perl soft=23, hard=23
      I think I've learnt something about 'my' too!
        That's your problem: my makes a variable lexical, and symbolic references only work with dynamic/global variables. BTW, this is also why mixing eval STRING with lexicals is problematic:
        foobar:perl/blead% perl -le '$y="print \$x"; $z=sub { my $x=23; $y}; e +val $z->()' foobar:perl/blead% perl -le '$y="print \$x"; $z=sub { $x=23; $y}; eval + $z->()' 23

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://952784]
[holli]: meh, i never get used to this keyboard
[holli]: i didnt pay attention when i bought it. it's one of those where backspace is just one unit wide
[holli]: in what way improved?
[ambrus]: I may have ruined my good keyboard on Friday by spilling tea in it. I hope it's just temporarily malfunctioning until it dries out, but I fear it might be permanently damaged.
[holli]: did you soak the controller boardlet?
[Eily]: could be worse, you might have ruined your tea with the content of the keyboard
[holli]: if you didnt you should be fine
LanX .oO( holli needs standards which are standardized!!)
[holli]: do i?
[holli]: oh for the keyboard

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2017-11-21 13:50 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (302 votes). Check out past polls.