IO(3pm)

✨ IO(3pm) β€” the Tk::IO tea πŸ’…

okay bestie, so this page is literally called Tk::IO and it lives in the 3pm section of the manual β€” the 3pm bit is the giveaway that it's a Perl module page, iykyk. Sit down, grab a boba, we're going in πŸ§‹βœ¨


🌸 NAME 🌸

Tk::IO β€” a high level interface to Tk's 'fileevent' mechanism. She's the glamorous front desk for the whole file-event situation. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

my $fh = Tk::IO->new(-linecommand => callback, -childcommand => callback);
$fh->exec("command")
$fh->wait
$fh->kill

That's the whole vibe right there. Make the object, run a command, wait on it, kill it. Chef's kiss. πŸ’…


πŸ”₯ WARNING πŸ”₯

INTERFACES TO THIS MODULE MAY CHANGE AS PERL'S IO EVOLVES AND WITH PORT OF TK4.1

fr fr, this is not a drill β€” the API here can and will move on you as Perl's IO grows up and as TK4.1 gets ported. Do not get attached to the exact shape of things. 😭


πŸ’– DESCRIPTION πŸ’–

So here's the lore: Tk::IO is now layered on perl's IO::Handle class. The interfaces have changed, and bestie, they are still evolving. It's giving glow-up in progress. 🌈

In theory, C methods which enable non-blocking IO as in earlier Tk-b* release(s) are still there. The author has not changed them to use perl's additional Configure information, or tested them much. So like… they're theoretically present. Whether they're thriving is another question entirely. πŸ™ˆ

The assumption β€” the whole premise of the bit β€” is that exec is used to fork a child process and a callback is called each time a complete line arrives up the implied pipe. ✨

"line" should probably be defined in terms of perl's input record separator but is not yet. Yeah. She said what she said. That definition has not happened yet. πŸ‘‘

The -childcommand callback is called when end-of-file occurs. 🌸

$fh->wait can be used to wait for child process while processing other Tk events. Very multitasking of her, we love a queen who can hold a conversation and keep the event loop fed at the same time. πŸ’œ

$fh->kill can be used to send signal to child process. Use it with intent, bestie β€” it's literally a signal being sent to a child process. 🫢


πŸ’€ BUGS πŸ’€

Still not finished. 😭

The idea is to use "exec" to emulate "system" in a non-blocking manner. So the dream is: all the power of system, none of the blocking. It is, at time of writing, a dream. No cap. 🌟


aaaand that's the whole page, bestie πŸŽ€ β€” this was IO(3pm), from perl v5.40.1, dated 2025-04-13. Mwah, love that for us. Go forth and non-block. πŸ¦‹πŸ’–βœ¨

πŸ“¦ where this page comes from