Re: Determining IO layer set on filehandle

2010-02-01 Thread Michael Ludwig
Am 29.01.2010 um 16:10 schrieb Aristotle Pagaltzis: > * Michael Ludwig [2010-01-29 15:50]: >> Like, does it work on all platforms? > > Ouch, good question. I don’t know whether Win32 supports dup’ing. I tried it out, it does. Same syntax, cross-platform. -- Michael.Ludwig (#) XING.com

Re: Determining IO layer set on filehandle

2010-01-29 Thread Michael Ludwig
Am 29.01.2010 um 19:44 schrieb Aristotle Pagaltzis: > Considering the relative complexities of the approaches and the > fact that conservation of filehandle state is not a concern in > your case, I know which solution *I* would favour… I absolutely agree. But it is interesting to learn about the

Re: Determining IO layer set on filehandle

2010-01-29 Thread Aristotle Pagaltzis
* Michael Ludwig [2010-01-29 18:30]: > It appears you can use that information to restore a filehandle > configuration: > > # Gut: STDOUT duplizieren und Duplikat umstellen. > # STDOUT (global) wird nicht verstellt. > sub out_bin_good { >open my $fh, '>&STDOUT' or die "dup STDOUT: $!"; >bi

Re: Determining IO layer set on filehandle

2010-01-29 Thread Michael Ludwig
Am 29.01.2010 um 17:28 schrieb Nicholas Clark: > On Fri, Jan 29, 2010 at 02:22:06PM +0100, Michael Ludwig wrote: >> Filehandles may have IO layers applied to them, like :utf8 or :raw. >> One of the ways to achieve that is to use the binmode() function. >> >> binmode $fh, ':utf8'; >> >> What I

Re: Determining IO layer set on filehandle

2010-01-29 Thread Nicholas Clark
On Fri, Jan 29, 2010 at 02:22:06PM +0100, Michael Ludwig wrote: > Filehandles may have IO layers applied to them, like :utf8 or :raw. > One of the ways to achieve that is to use the binmode() function. > > binmode $fh, ':utf8'; > > What I want to achieve is to set the STDOUT filehandle to ':raw

Re: Determining IO layer set on filehandle

2010-01-29 Thread Michael Ludwig
Am 29.01.2010 um 15:37 schrieb Aristotle Pagaltzis: > * Michael Ludwig [2010-01-29 14:20]: >> Is there an alternative way to achieve what I want, maybe >> involving one of the IO modules? > > You may want to just dup the filehandle and then diddle the dup’d > one. You may need to `seek $origfh,

Re: Determining IO layer set on filehandle

2010-01-29 Thread Aristotle Pagaltzis
* Michael Ludwig [2010-01-29 15:50]: > Like, does it work on all platforms? Ouch, good question. I don’t know whether Win32 supports dup’ing. Regards, -- Aristotle Pagaltzis //

Re: Determining IO layer set on filehandle

2010-01-29 Thread Michael Ludwig
Am 29.01.2010 um 15:37 schrieb Aristotle Pagaltzis: > * Michael Ludwig [2010-01-29 14:20]: >> Is there an alternative way to achieve what I want, maybe >> involving one of the IO modules? > > You may want to just dup the filehandle and then diddle the dup’d > one. You may need to `seek $origfh,

Re: Determining IO layer set on filehandle

2010-01-29 Thread Aristotle Pagaltzis
* Michael Ludwig [2010-01-29 14:20]: > Is there an alternative way to achieve what I want, maybe > involving one of the IO modules? You may want to just dup the filehandle and then diddle the dup’d one. You may need to `seek $origfh, (tell $dupfh), 0` afterwards. Not sure how much other state fil

Determining IO layer set on filehandle

2010-01-29 Thread Michael Ludwig
Filehandles may have IO layers applied to them, like :utf8 or :raw. One of the ways to achieve that is to use the binmode() function. binmode $fh, ':utf8'; What I want to achieve is to set the STDOUT filehandle to ':raw' and then to restore the previous IO layers. sub out_bin { binmode S