Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: A perl buffer

by leonidlm (Pilgrim)
on Aug 10, 2008 at 13:12 UTC ( [id://703411]=note: print w/replies, xml ) Need Help??


in reply to Re: A perl buffer
in thread A perl buffer

But how I can use it if I need it in a .pm module that acts like a container module, only subs... ?

Replies are listed 'Best First'.
Re^3: A perl buffer
by dreadpiratepeter (Priest) on Aug 10, 2008 at 14:00 UTC
    you would just say
    
    use Memoize;
    
    memoize('foo');
    sub foo {
    
    }
    
    And if you want to be diligent do a benchmark to see if it is quicker.
    Also, make sure that the functions have no side effects (io, setting global/package variables, etc)


    -pete
    "Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."
      Ahh now I see my problem:
      My function receiving different parameters. For example I configured a database retrive function. As a parameter I receive the sql statement. Sometimes my application will call this retrive function with the same sqlstatement, only in this case I want to memorize it and return the "memorized" image without retriving the data again.
      Now I hope I am clear :)
      BTW thanks everyone for helping.
        that's fine. that is exactly what memoize does. If you called your memoized function with
        func('select * from table1')
        the second time you ran it with that input, it would simply return the cached value from the first call.
        And that is fine, if you don't care that the data may have changed in the db in the meantime.


        -pete
        "Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."
Re^3: A perl buffer
by ikegami (Patriarch) on Aug 10, 2008 at 13:25 UTC
    Just like anywhere else? I don't see what's special.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-24 06:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found