Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Implementing filters as callbacks / hashrefs / regexes

by Zaxo (Archbishop)
on Jun 17, 2007 at 01:53 UTC ( [id://621641]=note: print w/replies, xml ) Need Help??


in reply to Implementing filters as callbacks / hashrefs / regexes

Your hash of coderefs is generally called a dispatch table in perl. It's an excellent choice, and a popular enough idiom to cause no confusion.

You may want to look into PerlIO::via, which addresses just your problem - preprocessing file I/O. It permits setting the processing scheme within the open mode argument, or with binmode.

After Compline,
Zaxo

  • Comment on Re: Implementing filters as callbacks / hashrefs / regexes

Replies are listed 'Best First'.
Re^2: Implementing filters as callbacks / hashrefs / regexes
by clinton (Priest) on Jun 17, 2007 at 11:11 UTC

    Hi Zaxo

    Your hash of coderefs is generally called a dispatch table in perl. It's an excellent choice, and a popular enough idiom to cause no confusion.

    It wasn't the dispatch table that I thought might cause the confusion, it was the fact that at object instantiation, I am "preresolving" each filter either to a coderef based on the parameter type (this part is fine), OR, to the codref returned by $self->can($filtername).

    This second step returns a coderef to either a subclassed version of the filter, or to the default filter. If, after instantiation, the developer were to programatically add/change the subclassed version of the filter, then only new objects would notice. I realise this is an edge case, but this is why I was asking.

    You may want to look into PerlIO::via, which addresses just your problem
    Have a look at Re^4: Implementing filters as callbacks / hashrefs / regexes - maybe my use of the word filter was a bad choice here. The loading of data is handled by other modules. My filters control how it is treated after loading.

    thanks

    Clint

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-18 14:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found