PipeOutput
PipeOutputArray
ReadFile
+ RequiredFields
RedirectOutput
StartPipe
Stats
=cut
-
$prompt ||= 'Password';
- my $password;
+ my $password = '';
local $| = 1;
last;
} # if
- print '*';
+ # Handle backspaces
+ if ($key eq chr(127)) {
+ unless ($password eq '') {
+ chop $password;
+
+ print "\b \b";
+ } # unless
+ } else {
+ print '*';
- $password .= $key;
+ $password .= $key;
+ } # if
} # while
ReadMode 'restore'; # Reset tty mode before exiting.
# TODO: Make it work on Windows...
return if $^O =~ /win/i;
- open my $loadAvg, '/proc/loadavg'
+ open my $loadAvg, '<', '/proc/loadavg'
or croak "Unable to open /proc/loadavg\n";
my $load = <$loadAvg>;
=cut
- open my $pipe, '|-', $to
+ open my $pipe, '|', $to
or error "Unable to open pipe - $!", 1;
foreach (@output) {
exit 1;
} # Usage
+sub RequiredFields($$) {
+
+=pod
+
+=head2 RequiredFields($total, $log)
+
+Check if a list of fields are contained in a hash
+
+Parameters:
+
+=for html <blockquote>
+
+=over
+
+=item $fields
+
+Array reference to a list of field names that are required
+
+=item $rec
+
+Hash reference whose key values we are checking
+
+=back
+
+=for html </blockquote>
+
+Returns:
+
+=for html <blockquote>
+
+=over
+
+=item Message
+
+Returns either an empty string or a string naming the first missing required
+field
+
+=back
+
+=for html </blockquote>
+
+=cut
+
+ my ($fields, $rec) = @_;
+
+ for my $fieldname (@$fields) {
+ my $found = 0;
+
+ for (keys %$rec) {
+ if ($fieldname eq $_) {
+ $found = 1;
+ last;
+ } # if
+ } # for
+
+ return "$fieldname is required" unless $found;
+ } # for
+
+ return;
+} # RequiredFields
+
END {
StopPipe;
} # END