X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXUtil.pm;h=512c30efcc0e35609c3d931f0c20bf172af517ef;hb=refs%2Fheads%2Fip_address;hp=e3056e95e05a59cc78c81adaa058428bc34d497b;hpb=b9dffeff7239952814342dad19db3a51def6fab7;p=spider.git diff --git a/perl/DXUtil.pm b/perl/DXUtil.pm index e3056e95..512c30ef 100644 --- a/perl/DXUtil.pm +++ b/perl/DXUtil.pm @@ -3,7 +3,7 @@ # # Copyright (c) 1998 - Dirk Koopman G1TLH # -# $Id$ +# # package DXUtil; @@ -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; @@ -434,3 +448,4 @@ sub deleteitem @$list = grep {$_ ne $item } @$list; return $n - @$list; } +