Re: Is this possible to override print() ?



Sorry... the email is unfinished, the reason why I need to do this is
because
I don't want to pollute the existed codes / context ... the original print
statements would
like to retain, but I can still do the translations by adding :
use OverridePrint;
in a common module that all existed scripts are now using.

package OverridePrint;


use strict;

# WHAT CAN I DO HERE ???

1;

# Main Program


use OverridePrint;

print "Goodbye World" ; # I got "GBK : Goodbye World"

$mode = "BIG5" ;
print "Hello World" ; # I got "BIG5 : Hello World"

I don't want to write another sub like Print ( $case, $mesg ) , but
directly override the print behavior.

In the real story, the structure is more complex. Default will print in
English, with user request ( argv ),
will print in BIG5 CHinese, and with Browser detection, will translate to
GBK.


Relevant Pages

  • Re: Is this possible to override print() ?
    ... I don't want to pollute the existed codes / context ... ... use OverridePrint; ... You can find out whether or not a core function can be overridden by ... calling the prototype* function with that function's name prepended ...
    (perl.beginners)
  • Re: Is this possible to override print() ?
    ... I don't want to pollute the existed codes / context ... ... use OverridePrint; ... there is another way: source filters. ... whatever special behaviour you need for a tied filehandle ...
    (perl.beginners)