Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Associating filehandles with Perl::Tk widgets?

by pc88mxer (Vicar)
on Jul 16, 2008 at 18:36 UTC ( [id://698107]=note: print w/replies, xml ) Need Help??


in reply to Associating filehandles with Perl::Tk widgets?

You can access the formatting routines without using a filehandle. See the section "Accessing Formatting Internals" in perldoc perlform.

Another option is to use a file handle that is tied to a scalar variable, format the text using that file handle and retrieve the formatted output via the scalar:

my $buf; open(my $fh, ">", \$buf); ... write $fh ...; ... close($fh); # now use $buf: $widget->configure(-text => $buf);

Replies are listed 'Best First'.
Re^2: Associating filehandles with Perl::Tk widgets?
by YYCseismic (Beadle) on Jul 16, 2008 at 19:27 UTC

    Okay, that's awesome! I used the first option, and that takes care of a couple of my problems! It's really nice, because I don't have to worry about newlines, either. The only thing is I get the following warning: Use of uninitialized value in formline at ./sl-brad.pl line 375. Here's my code:

    sub swrite { croak "Usage: swrite PICTURE ARGS" unless @_; my $format = shift; $^A = ""; formline( $format, @_ ); return $^A; } #end sub swrite()

    I know it's just a warning, but I'm looking for clean code. I assume it's not liking the @_ in the formline statement. Perhaps I should just assign it to another variable?

      Problem solved. Turned out the data I was sending to swrite was not quite right. Now it is and all is beautiful :) Thanks for your help!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://698107]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-25 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found