in reply to Re: Should we bother to save hash lookups for performance? (yes, sometimes)
in thread Should we bother to save hash lookups for performance?

This becomes especially useful when there exists and you need to access several things at a given level.

my $port = $self->{center}{floor}{room}{bay}{rack}{unit}{port}; unless ( --$port->{timecount} ) { unless ( $port->{transmitted} or $port->{received} ) { close( $port->{handle} ); } else { $port->{timecount} = $port->{timeout}; $port->{transmitted} = $port->{recieved} = 0; } }

This neatly emulates the Pascal-style with ... statement.

I guess you could even use my $with_port = ... but that would be altogether to cute (and extra to type:^).


Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!

Replies are listed 'Best First'.
Re^3: Should we bother to save hash lookups for performance? (yes, sometimes)
by Aristotle (Chancellor) on Oct 19, 2002 at 20:29 UTC
    for($self->{center}{floor}{room}{bay}{rack}{unit}{port}) { last if --$_->{timecount}; close($_->{handle}), last unless $_->{transmitted} or $_->{received} $_->{timecount} = $_->{timeout}; $_->{transmitted} = $_->{recieved} = 0; }

    Makeshifts last the longest.

      ...BUT, BUT, BUT...it was only pseudo-code.... Aristotle++

      You can tell its a slow weekend at PM when you start optomisiing my pseudo-code:)


      Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!
        Oh, I wasn't just being facetious. :) I meant that you can use for in Perl like you use with in Pascal. Larry himself called for a "topicalizer". I love it for that use, too. I'll even use it as an expression modifier to topicalize a variable for a single expression like I said in my previous reply on this thread.

        Makeshifts last the longest.