http://www.fmi.uni-passau.de/archive/doc/unix/perl/faq/1.24.html (Einblicke ins Internet, 10/1995)
How can I use X with Perl?
How can I use X with Perl?
Right now, you have several choices. You can wait for perl5, use
the WAFE or STDWIN packages, or try to make your own usub bindings.
Perl5 is anticipated to be released with bindings for X, called
guiperl. An exciting prototype for this, written by Jon Biggar
<jon@netlabs.com>, Larry's *other* brother-in-law and officemate,
is already up and running inside of Netlabs. This program addresses
the same dynamic gui-building problem space as does tcl/tk.
If you can't wait or don't think that guiperl will do what you want,
a stab at Motif bindings was begun by Theodore C. Law
<TEDLAW@TOROLAB6.VNET.IBM.COM> area. His article about this is
on convex.com in /pub/perl/info/motif for anon ftp.
STDWIN is a library written by Guido van Rossum <guido@cwi.nl>
(author of the Python programming language) that is portable
between Mac, Dos and X11. One could write a Perl agent to
speak to this STDWIN server.
WAFE is a package that implements a symbolic interface to the Athena
widgets (X11R5). A typical Wafe application consists in our framework
of two parts: the front-end (we call it Wafe for Widget[Athena]front
end) and an application program running typically as separate process.
The application program can be implemented in an arbitrary programming
language and talks to the front-end via stdio. Since Wafe (the
front-end) was developed using the extensible TCL shell (cite John
Ousterhout), an application program can dynamically submit requests to
the front-end to build up the graphical user interface; the
application can even down-load application specific procedures into
the front-end. The distribution contains sample application programs
in Perl, GAWK, Prolog, TCL, and C talking to the same Wafe binary.
Many of the demo applications are implemented in Perl. Wafe 0.9 can
be obtained via anonymous ftp from
ftp.wu-wien.ac.at:pub/src/X11/wafe-0.9.tar.Z
(for people without name server: the ip address is 137.208.3.5)
Alternatively, you could use wish from tcl.
#!/usr/local/bin/perl
#####################################################################
# An example of calling wish as a subshell under Perl and
# interactively communicating with it through sockets.
#
# The script is directly based on Gustaf Neumann's perlwafe script.
#
# Dov Grobgeld dov@menora.weizmann.ac.il
# 1993-05-17
#####################################################################
$wishbin = "/usr/local/bin/wish";
die "socketpair unsuccessful: $!!\n" unless socketpair(W0,WISH,1,1,0);
if ($pid=fork) {
select(WISH); $| = 1;
select(STDOUT);
# Create some TCL procedures
print WISH 'proc echo {s} {puts stdout $s; flush stdout}',"\n";
# Create the widgets
print WISH <<TCL;
# This is a comment "inside" wish
frame .f -relief raised -border 1 -bg green
pack append . .f {top fill expand}
button .f.button-pressme -text "Press me" -command {
echo "That's nice."
}
button .f.button-quit -text quit -command {
echo "quit"
}
pack append .f .f.button-pressme {top fill expand} \\
.f.button-quit {top expand}
TCL
;
# Here is the main loop which receives and sends commands
# to wish.
while (<WISH>) {
chop;
print "Wish sais: <$_>\n";
if (/^quit/) { print WISH "destroy .\n"; last; }
}
wait;
} elsif (defined $pid) {
open(STDOUT, ">&W0");
open(STDIN, ">&W0");
close(W0);
select(STDOUT); $| = 1;
exec "$wishbin --";
} else {
die "fork error: $!\n";
}