The advantage of subclassing might be that you can keep the effects of overriding local to where you actually need it. Overriding the system builtin with
BEGIN {
*CORE::GLOBAL::connect = sub (*$) {
...
}
}
would (as the ::GLOBAL hints at) be global — which might or might not be what you really want...
I'm not really sure I understand your basic design: why would an existing socket be passed to your myconnect(), which cannot really be used, and thus needs to be replaced or "merged" with another one? Why not create a proper one in the first place? What is the relation of the existing socket with the new custom one, i.e. what functionality or data would it share? Could you elaborate on your usage context? |