How to determine what operating system you're running on:
$^O predefined variable as per the perlvar man page.
How to figure out where to save configuration files for the current operating system:
def config_home() -> str:
"""Get storage dir for user config files as per the XDG spec."""
if os.getenv("XDG_CONFIG_HOME"):
return str(os.getenv("XDG_CONFIG_HOME"))
elif sys.platform.startswith("haiku"):
result = subprocess.run(
["finddir", "B_USER_SETTINGS_DIRECTORY"],
capture_output=True)
return result.stdout.decode()
else:
return os.path.join(str(os.getenv("HOME")), ".config")
How to use the dialog utility from Tcl:
package require Tcl 8.5
set temp [file tempfile]
exec dialog --inputbox "What's your name?" 0 0 <@ stdin >@ stdout 2>@ $temp
seek $temp 0
exec dialog --msgbox "Hello, [read $temp]" 0 0 <@ stdin >@ stdout
seek $temp 0
chan truncate $temp
exec dialog --inputbox "What's up?" 0 0 <@ stdin >@ stdout 2>@ $temp
seek $temp 0
puts "[read $temp] is cool!"
How to use dialog from Perl:
use warnings;
use strict;
use IPC::Open3 'open3';
use Symbol 'gensym';
system "dialog", "--msgbox", "Hello, world!", "0", "0";
my $pid = open3('<&STDIN', '>&STDOUT', my $dlgout = gensym,
"dialog", "--inputbox", "What's your name?", "0", "0");
waitpid($pid, 0);
print "Nice to meet you, ", <$dlgout>, "!\n";
close $dlgout;
Note: Perl also has the UI::Dialog library (packaged in Debian as libui-dialog-perl). Other solutions:
the site for things related to the awk language