Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to redirect my $fh to STDOUT?

Reply
Thread Tools

How to redirect my $fh to STDOUT?

 
 
bill
Guest
Posts: n/a
 
      12-23-2004




I'm debugging a script not written by me, and having a rough time
of it (it is a huge script with no subroutines; uses no modules;
etc.). Near the top of the file (i.e. near the beginning of this
script's execution), a lexical filehandle is opened for writing,
and remains open throughout. It would be useful if I could redirect
this lexical filehandle to STDOUT. I've read the docs on "duplicating"
filehandles, but I confess that I don't quite understand them.
Could someone show me how I'd redirect an open lexical write handle
from a file to STDOUT?

Thanks!

bill

 
Reply With Quote
 
 
 
 
A. Sinan Unur
Guest
Posts: n/a
 
      12-23-2004
bill <(E-Mail Removed)> wrote in news:cqd9e0$3i4$1
@reader1.panix.com:

> I'm debugging a script not written by me, and having a rough time
> of it (it is a huge script with no subroutines; uses no modules;
> etc.).


Good luck.

> Near the top of the file (i.e. near the beginning of this
> script's execution), a lexical filehandle is opened for writing,
> and remains open throughout. It would be useful if I could redirect
> this lexical filehandle to STDOUT.


Would the following do what you want?

#! perl

use strict;
use warnings;

# open my $fh, '>', 'somefile' or die $!;
my $fh = \*STDOUT;

print $fh "This should print to STDOUT\n";


--
A. Sinan Unur
http://www.velocityreviews.com/forums/(E-Mail Removed)d
(remove '.invalid' and reverse each component for email address)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Response.redirect does not redirect from .aspx page =?Utf-8?B?VHJveQ==?= ASP .Net 3 10-15-2008 09:07 PM
Redirect to secure FTP site via response.redirect Ron Howard ASP General 2 08-11-2004 07:40 PM
Redirect LPT1 to COM4 for Bluetooth printing Bitman Wireless Networking 3 07-22-2004 06:19 PM
Basic Q - Response.Redirect, all redirect to first Response.Redirect statement Sal ASP .Net Web Controls 1 05-15-2004 03:46 PM



Advertisments