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 <hpa@linux.intel.com>
This commit is contained in:
parent
8fe1f65087
commit
0e7370cfa6
2 changed files with 26 additions and 26 deletions
|
@ -169,32 +169,6 @@ sub gen_perfect_hash($) {
|
|||
return;
|
||||
}
|
||||
|
||||
#
|
||||
# Read input file
|
||||
#
|
||||
sub read_input() {
|
||||
my $key,$val;
|
||||
my %out;
|
||||
my $x = 0;
|
||||
|
||||
while (defined($l = <STDIN>)) {
|
||||
chomp $l;
|
||||
$l =~ s/\s*(\#.*|)$//;
|
||||
|
||||
next if ($l eq '');
|
||||
|
||||
if ($l =~ /^([^=]+)\=([^=]+)$/) {
|
||||
$out{$1} = $2;
|
||||
$x = $2;
|
||||
} else {
|
||||
$out{$l} = $x;
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
|
||||
return %out;
|
||||
}
|
||||
|
||||
#
|
||||
# Verify that the hash table is actually correct...
|
||||
#
|
||||
|
|
26
phash.pl
26
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 = <STDIN>)) {
|
||||
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
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue