- my ($line, $value) = @_;
- my ($priv, $prompt, $action) = split ',', $line;
-
- # if there is an action treat it as a subroutine and replace $value
- if ($action) {
- my $q = qq{\$value = $action(\$value)};
- eval $q;
- }
- $prompt = sprintf "%15s: %s", $prompt, $value;
- return ($priv, $prompt);
+ my ($line, $value) = @_;
+ my ($priv, $prompt, $action) = split ',', $line;
+
+ # if there is an action treat it as a subroutine and replace $value
+ if ($action) {
+ my $q = qq{\$value = $action(\$value)};
+ eval $q;
+ }
+ $prompt = sprintf "%15s: %s", $prompt, $value;
+ return ($priv, $prompt);
+}
+
+# take an arg as an array list and print it
+sub parray
+{
+ my $ref = shift;
+ return join(', ', @{$ref});
+}
+
+# take the arg as an array reference and print as a list of pairs
+sub parraypairs
+{
+ my $ref = shift;
+ my $i;
+ my $out;
+
+ for ($i = 0; $i < @$ref; $i += 2) {
+ my $r1 = @$ref[$i];
+ my $r2 = @$ref[$i+1];
+ $out .= "$r1-$r2, ";
+ }
+ chop $out; # remove last space
+ chop $out; # remove last comma
+ return $out;