<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<tt>The main point of the exercise was so that I could do something
like:<br>
<br>
use MyPrint;<br>
print "Blah";<br>
<br>
which outputs:<br>
<br>
MyPrint: Blah<br>
<br>
rather than:<br>
<br>
Blah<br>
<br>
The purpose being that I simply want to delete the 'use MyPrint;' line
to restore the normal Perl behaviour.<br>
Using IO::Wrap doesn't give that as I would have to change the syntax
to:<br>
<br>
use IO::Wrap;<br>
no warnings;<br>
sub IO::Wrap::print {<br>
my $self = shift;<br>
print { $$self } "IO::Wrapped: ", @_;<br>
}<br>
use warnings;<br>
wraphandle(\*STDOUT);<br>
print "Blah";<br>
<br>
or something similar. However, this doesn't override 'print' as it
produces the output:<br>
<br>
Blah<br>
<br>
rather than what is wanted:<br>
<br>
IO::Wrapped: Blah<br>
<br>
Hope this explains,<br>
Mathew<br>
</tt><br>
Joshua Goodall wrote:
<blockquote cite="mid20060321235641.GX46507@roughtrade.net" type="cite">
<pre wrap="">On Wed, Mar 22, 2006 at 10:32:10AM +1100, Mathew Robertson wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Thats an interesting question, and one that I will eventually tackle.
The whole concept of overriding 'print' itself is fundamentally suspect,
so I'm specifically trying to *not* allow flexible useage of the package.
</pre>
</blockquote>
<pre wrap=""><!---->
was there a reason you couldn't just create a wrapper class derived
from IO::Wrap or whatever? The wrapper class could then just munge
the print call on the way through.
depends on your code architecture I guess, but the OO way is nice :)
</pre>
</blockquote>
</body>
</html>