Main page...           Popular tags: Electronics (11), Linux (11), Hack (8), DIY (6), Other (6), Retrocomputing (6), Debian (5), Curiosities (4)

Perl::Tk and "is not a hash" error

2016-08-09 19:23:13,  In: Linux, Perl, Debian

In Debian 8 (Jessie), after installing Perl::Tk, all scripts return the following error whenever Perl::Tk main loop is called:
2773678 is not a hash at /usr/local/lib/x86_64-linux-gnu/perl/5.20.2/Tk/ line 53.
Line number may be different depending on Tk library version. Path usually will be different too (your architecture may differ), the most important thing here is this is not a hash error. The source of this problem is with using legacy form color parameter. In earlier X Window versions, colors responsible for window theming were stored as X Window system resources. This was never done completely in Linux, and the last desktop which done it in larger part was CDE from 1990s, and most Linux software just ignored parameters if there were any. However, some definitions survived until few years ago X have been updated. But Perl::Tk still needs some colour definition in order to generate a dialog window - it needs to know the background color.
To solve this problem, edit (or create) file called .Xresources in your home directory adding these lines:
*.background: gray75
*.BACKGROUND: gray75

Then apply the settings:
xrdb -merge ~/.Xresources
Most window managers load .Xresources
file automatically at startup. However, there are some exceptions. You may need to run xrdb before starting your script every boot. You can do it on start of X system by adding the following line to your .xinitrc file:
[[ -f ~/.Xresources ]] && xrdb -merge ~/.Xresources
Another way is to use .Xdefaults file, which, traditionally, should be loaded at startup, but if you specify other values by another program running in the start-up first, you mat get conflict. Making programs read not their values is a bad design process, but sometimes it is present in older Linux applications.

Older post...       Main page       Newer post...