summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/dumpvar.pl15
-rw-r--r--lib/flush.pl22
-rw-r--r--lib/importenv.pl4
3 files changed, 35 insertions, 6 deletions
diff --git a/lib/dumpvar.pl b/lib/dumpvar.pl
index b8cff8952c..b3fb02b00a 100644
--- a/lib/dumpvar.pl
+++ b/lib/dumpvar.pl
@@ -1,25 +1,32 @@
package dumpvar;
+# translate control chars to ^X - Randal Schwartz
+sub unctrl {
+ local($_) = @_;
+ s/([\001-\037\177])/'^'.pack('c',ord($1)^64)/eg;
+ $_;
+}
sub main'dumpvar {
- ($package) = @_;
+ ($package,@vars) = @_;
local(*stab) = eval("*_$package");
while (($key,$val) = each(%stab)) {
{
+ next if @vars && !grep($key eq $_,@vars);
local(*entry) = $val;
if (defined $entry) {
- print "\$$key = '$entry'\n";
+ print "\$$key = '",&unctrl($entry),"'\n";
}
if (defined @entry) {
print "\@$key = (\n";
foreach $num ($[ .. $#entry) {
- print " $num\t'",$entry[$num],"'\n";
+ print " $num\t'",&unctrl($entry[$num]),"'\n";
}
print ")\n";
}
if ($key ne "_$package" && defined %entry) {
print "\%$key = (\n";
foreach $key (sort keys(%entry)) {
- print " $key\t'",$entry{$key},"'\n";
+ print " $key\t'",&unctrl($entry{$key}),"'\n";
}
print ")\n";
}
diff --git a/lib/flush.pl b/lib/flush.pl
new file mode 100644
index 0000000000..1d22819ab8
--- /dev/null
+++ b/lib/flush.pl
@@ -0,0 +1,22 @@
+;# Usage: &flush(FILEHANDLE)
+;# flushes the named filehandle
+
+;# Usage: &printflush(FILEHANDLE, "prompt: ")
+;# prints arguments and flushes filehandle
+
+sub flush {
+ local($old) = select(shift);
+ $| = 1;
+ print "";
+ $| = 0;
+ select($old);
+}
+
+sub printflush {
+ local($old) = select(shift);
+ $| = 1;
+ print @_;
+ $| = 0;
+ select($old);
+}
+
diff --git a/lib/importenv.pl b/lib/importenv.pl
index c321a20219..db3128be43 100644
--- a/lib/importenv.pl
+++ b/lib/importenv.pl
@@ -1,8 +1,8 @@
-;# $Header: importenv.pl,v 3.0 89/10/18 15:19:39 lwall Locked $
+;# $Header: importenv.pl,v 3.0.1.1 90/08/09 03:56:38 lwall Locked $
;# This file, when interpreted, pulls the environment into normal variables.
;# Usage:
-;# do 'importenv.pl';
+;# require 'importenv.pl';
;# or
;# #include <importenv.pl>