in reply to Re^2: Is { } an empty block or a bug in perl?
in thread Is { } an empty block or a bug in perl?

I was thinking of things like this, where the assignment is done later:
sub gimme_my_data { my $self = shift; $self->{data} || {} }
you could use a code block there too if you want to ( || do { ... }).

Replies are listed 'Best First'.
Re^4: Is { } an empty block or a bug in perl?
by thor (Priest) on Jul 06, 2005 at 22:51 UTC
    After I wrote the initial reply this morning, I was thinking that it might be this sort of thing. I like to use an explicit return in my subs, so I guess I wouldn't run into this problem.

    thor

    Feel the white light, the light within
    Be your own disciple, fan the sparks of will
    For all of us waiting, your kingdom will come

        I understand that a subroutine returns the last statement evaluated. I just like the explicit return. It's just a matter of preference.

        thor

        Feel the white light, the light within
        Be your own disciple, fan the sparks of will
        For all of us waiting, your kingdom will come