<!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>'override' is what I would prefer.<br>
<br>
If I overload '""' all kinds of weird stuff can happen, 'depending on
context...' - but the end-result is not really what I am aiming for
either... :-(<br>
<br>
Mathew<br>
</tt><br>
Sisyphus wrote:
<blockquote cite="mid01ab01c6498e$0e400c60$ceff583d@desktop" type="cite">
  <pre wrap="">----- Original Message ----- 
From: "Mathew Robertson" <a class="moz-txt-link-rfc2396E" href="mailto:mathew.robertson@netratings.com.au">&lt;mathew.robertson@netratings.com.au&gt;</a>
To: "Perl Mongers" <a class="moz-txt-link-rfc2396E" href="mailto:melbourne-pm@pm.org">&lt;melbourne-pm@pm.org&gt;</a>
Sent: Friday, March 17, 2006 4:33 PM
Subject: [Melbourne-pm] overloading 'print'


  </pre>
  <blockquote type="cite">
    <pre wrap="">Hi folks,

I have a situation where I would like to overload the 'print' and 
'printf' functions, so that I can do some translation stuff in them. 
    </pre>
  </blockquote>
  <pre wrap=""><!---->
If you really want to overload, rather than override then something like:

package Foo;
use warnings;

use overload '""'   =&gt; \&amp;overload_print;

$z = Foo-&gt;new(8);

print $z, "\n";


sub new {
    my ($class, $val) = @_;
    my $self = {value =&gt; $val};
    bless $self, $class;
    return $self;
}

sub overload_print {
    my $ret = 'The value I want is ';
    my $p = $_[0]-&gt;{value};
    $ret .= $p * 7;
}

__END__

Not sure if that's what you want to do.

Cheers,
Rob

  </pre>
</blockquote>
</body>
</html>