RE: write, print, & Tk::Text
- From: JohnCortland.Morgan@xxxxxxxxxxxx (John Cortland Morgan)
- Date: Tue, 28 Nov 2006 12:48:42 +0100
Hi,
Thanks for your reply, but still questions... You're right about this:
line errors$ofh = *LOG; # using this instead of *STDOUT gives command
Well you don't open LOG anywhwere. STDOUT, STDIN, AND STDERR arepredefined filehandles, so you can get away with it.
I don't open LOG anywhere, I only tie to it after creating the Tk::Text
widget (actually,a Tk::Scrolled widget).
tie (*LOG, 'Tk::Text', $log);
But if it is not an open filehandle, why does my subroutine work?
#--------------------------------------------------
sub logit() {
return unless $log;
# this always prints to Tk::Text widget correctly
for (@_) { print LOG $_, "\n"; }
}
#--------------------------------------------------
and if it is an open filehandle, why doesn't this work:
$ofh = *LOG; # using this instead of *STDOUT gives command line
errors
As I said, maybe it's not a true filehandle???
I'm a little confused as to what you are trying to do.substitute the text widget for the log file?
Are you trying to monitor an external log file, or are you trying to
Started out as just a way to show debugging info in the gui, instead of
on command line.
Then went to writing a report to the gui. But now I'd just like to
understand why
print will print to LOG but write will not write to it.
Thanks,
John
-----Original Message-----
From: Linux@xxxxxxxxxxxxxxxxxxxx [mailto:Linux@xxxxxxxxxxxxxxxxxxxx] On
Behalf Of zentara
Sent: Friday, November 24, 2006 5:22 PM
To: beginners@xxxxxxxx
Subject: Re: write, print, & Tk::Text
On Thu, 23 Nov 2006 14:24:20 +0100, JohnCortland.Morgan@xxxxxxxxxxxx
("John Cortland Morgan \(ZG/ETK\)") wrote:
Hi All,
I'm writing a perl application using Tk for the gui, and wish to write
formatted output to a logging window within the gui. But I cannot get
write to do as I wish, and think that I don't really understand
filehandles so well. Any insight on them would be greatly appreciated.
$ofh = *LOG; # using this instead of *STDOUT gives commandline errors
Well you don't open LOG anywhwere. STDOUT, STDIN, AND STDERR are
predefined filehandles, so you can get away with it.
I'm a little confused as to what you are trying to do.
Are you trying to monitor an external log file, or are you trying to
substitute the text widget for the log file?
If you are just looking to write formatted text to the text widget, you
could forget about the format_name("SOURCES") ,and just avoid the
filehandle mixup, by a
$temp=sprintf("%-55s %-30s %-10s %-16s %-10s\n", $i,$j,$k,$m,$n);
&disp($temp);
sub disp {
my $message=shift;
$txt -> insert('end',$message);
print "$message";
}
You could also try asking this on comp.lang.perl.tk if you really want
to use Filehandle's format_name.
Some smart Text gurus hang out there.
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx For additional
commands, e-mail: beginners-help@xxxxxxxx <http://learn.perl.org/>
<http://learn.perl.org/first-response>
.
- Prev by Date: Re: failed substitution
- Previous by thread: write, print, & Tk::Text
- Next by thread: postgres insert
- Index(es):