in reply to Typeglob substitution in objects based typeglob
I'm not sure I'm understanding you correctly, but it somehow sounds like you want to subclass IO::Socket or IO::Socket::INET, and override selected methods with your own implementations (?) Calls to other methods would then be forwarded to the superclass...
#!/usr/bin/perl -w use strict; package IO::Socket::WhatEver; use IO::Socket::INET; use base "IO::Socket::INET"; sub connect { print "doing my own stuff in connect()...\n"; my $sock = shift; return $sock->SUPER::connect(@_); } package main; my $mysock = IO::Socket::WhatEver->new( PeerAddr => 'perlmonks.org', PeerPort => 'http(80)', Proto => 'tcp', ); # ...
$ ./883113.pl doing my own stuff in connect()...
Instead of calling $sock->SUPER::connect(...) in the overridden method (which eventually calls the connect() builtin), you can of course also call your own low-level connect() implementation... provided it does something which is compatible with what the regular builtin would do.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Typeglob substitution in objects based typeglob
by OlegG (Monk) on Jan 19, 2011 at 13:47 UTC | |
by Anonymous Monk on Jan 19, 2011 at 13:59 UTC | |
by OlegG (Monk) on Jan 19, 2011 at 15:19 UTC |