From 0e7370cfa64b9cfe81d4ce9a5f0a07203836f9c7 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Wed, 22 Sep 2010 14:02:28 -0700 Subject: phash: move sample function to the sample file read_input() shouldn't be part of the phash.ph module; instead it should go into the sample usage file phash.pl. Signed-off-by: H. Peter Anvin --- phash.pl | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'phash.pl') diff --git a/phash.pl b/phash.pl index e1071b2..cc9ca74 100755 --- a/phash.pl +++ b/phash.pl @@ -37,6 +37,32 @@ require 'phash.ph'; +# +# Read input file +# +sub read_input() { + my $key,$val; + my %out; + my $x = 0; + + while (defined($l = )) { + chomp $l; + $l =~ s/\s*(\#.*|)$//; + + next if ($l eq ''); + + if ($l =~ /^([^=]+)\=([^=]+)$/) { + $out{$1} = $2; + $x = $2; + } else { + $out{$l} = $x; + } + $x++; + } + + return %out; +} + # # Main program # -- cgit v1.2.3