in reply to The trouble with Perl Idiom

Say, what's the deal with transforming every element of @_ after the first but then returning the second element? You never get constant values as parameters?

Anyhow, if you write code as list-processing stuff with nice indentation you get something that even looks Pythony. What could be prettier than that?

sub getRef { shift; # !!! $this is a global return map ref $this->getNodeById( $_ ), grep $_ && not ref, @_; }

Replies are listed 'Best First'.
Re^2: The trouble with Perl Idiom
by PodMaster (Abbot) on Aug 27, 2004 at 06:34 UTC
    Pretty :)
    sub getRef { my $self = shift; $_ and ref $_ and $_ = $self->getNodeById($_) for @_; ref shift; }

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re^2: The trouble with Perl Idiom
by demerphq (Chancellor) on Aug 26, 2004 at 19:39 UTC

    I think its so you can say stuff like

    if (getRef($node)) { ... }

    and be sure that $node is now indeed a PM $NODE hashref. As I said, this isn't a technique I would probably employ. I'm sure the Everything folks have their reasons, but to me its an odd routine in the first place.

    Oh, i should say, that for a lot of PM methods there are functional wrappers, so where the normal $obj->getRef($node) would be written in htmlcode it would be as a plain getRef() call.


    ---
    demerphq

      First they ignore you, then they laugh at you, then they fight you, then you win.
      -- Gandhi


      I'm sure the Everything folks have their reasons

      Let me assure you, they're not good ones and that code wouldn't look the same today.