X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXUtil.pm;h=512c30efcc0e35609c3d931f0c20bf172af517ef;hb=c1540ccd7990ec4bd151604dd63583d19fe4d0f6;hp=608102e8a393db0b87a2734374f013696c975624;hpb=7a3918d750c1afaf42ab26eb89a7df9033ca9f37;p=spider.git diff --git a/perl/DXUtil.pm b/perl/DXUtil.pm index 608102e8..512c30ef 100644 --- a/perl/DXUtil.pm +++ b/perl/DXUtil.pm @@ -20,7 +20,7 @@ use vars qw(@month %patmap @ISA @EXPORT); require Exporter; @ISA = qw(Exporter); @EXPORT = qw(atime ztime cldate cldatetime slat slong yesno promptf - parray parraypairs phex shellregex readfilestr writefilestr + parray parraypairs phex phash shellregex readfilestr writefilestr filecopy ptimelist print_all_fields cltounix unpad is_callsign is_latlong is_qra is_freq is_digits is_pctext is_pcflag insertitem deleteitem @@ -194,7 +194,7 @@ 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]; @@ -205,6 +205,20 @@ sub parraypairs return $out; } +# take the arg as a hash reference and print it out as such +sub phash +{ + my $ref = shift; + my $out; + + while (my ($k,$v) = each %$ref) { + $out .= "${k}=>$v, "; + } + chop $out; # remove last space + chop $out; # remove last comma + return $out; +} + sub _sort_fields { my $ref = shift;