For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2006 > Is that possible to tie print ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Is that possible to tie print ?
Mug

2006-10-04, 9:57 pm

Dear List,

I have a module that converts Chinese text between Big5 and GB2312.
and I have write my own /PrintCh() /as an exported sub.

However, I am looking for more, can I silently /tie print() /or /tie
STDOUT /
something ? and whenever I /print()/ anything, it will pass to my script
to detect
remote browser's default language and to do the translation, and print
out proper
/charset/ content ?

Thanks in advise,
Mug



Peter Scott

2006-10-05, 7:57 am

On Thu, 05 Oct 2006 10:43:38 +0800, Mug wrote:
> I have a module that converts Chinese text between Big5 and GB2312.
> and I have write my own /PrintCh() /as an exported sub.
>
> However, I am looking for more, can I silently /tie print() /or /tie
> STDOUT /
> something ? and whenever I /print()/ anything, it will pass to my script
> to detect
> remote browser's default language and to do the translation, and print
> out proper /charset/ content ?


You wouldn't tie print(), you would override it. Except that you can't,
because print() is one of a few non-overridable functions due to its
special syntax (the optional filehandle). You could tie STDOUT; see
perldoc perltie and scroll down to 'Tying Filehandles'.

--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com