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

Re: :lvalue, How I Hate Thee

by BrowserUk (Patriarch)
on Aug 17, 2005 at 19:38 UTC ( [id://484557]=note: print w/replies, xml ) Need Help??


in reply to :lvalue, How I Hate Thee

At one point, I have to figure out why this didn't work:

Define "didn't work"? In what way didn't it work?

This compiles and runs without error:

#! perl -slw use strict; package thing; sub new { bless {}, $_[0]; } sub value :lvalue { my $this = shift; $this->{VALUE};} package main; my $thing = thing->new; $thing->value = undef;

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

Replies are listed 'Best First'.
Re^2: :lvalue, How I Hate Thee
by jk2addict (Chaplain) on Aug 17, 2005 at 19:40 UTC

    Didn't work, as in $self->{VALUE} maintained it's original value of 'Yes', instead of being set to undef.

    What version ot perl was that under?

      5.8.4, but I think you're right that there is something else involved here.

      #! perl -slw use strict; package thing; sub new { bless { VALUE => 'YES' }, $_[0]; } sub value :lvalue { my $this = shift; $this->{VALUE}; } package main; print $]; my $thing = thing->new; print $thing->value; $thing->value = undef; print $thing->value; __END__ P:\test>junk2 5.008004 YES Use of uninitialized value in print at P:\test\junk2.pl line 22.

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
        Worked fine for me in 5.8.2:

        5.008002
        YES
        Use of uninitialized value in print at undeftest.pl line 22.

        --DrWhy

        "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

Re^2: :lvalue, How I Hate Thee
by jk2addict (Chaplain) on Aug 17, 2005 at 19:57 UTC

    It works on one machine, but not the other. One is perl 5.8.3 and the other is 5.8.6, but it feels like something else is afoot....

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://484557]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-20 02:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found