in reply to Parsing/Comparing
If this is a repetitive task that you're performing on each of your $mcc, $mnc, $lac, etc. variables, then the easiest way to eliminate the repetitive code is to put the values into an array or hash and use a loop to iterate over all of them. I'd use a hash in your case. For example:
my @fieldnames = qw/cellsiteID sectID mcc mnc lac ci bscid bts bearin +g mscID lat long tilt agl/; my %hash; # you'll want a better name :-) while (<OSS>) { @hash{@fieldnames} = split /,/; my %new = %hash; # new values go here my $key = join "_", @hash{'cellsiteID','sectID'}; next unless exists $h_ssect{$key}; my @scoutSA = split(/,/,$h_ssect{$key}); for my $f (@fields) { if ($hash{$f} ne $scoutSA[$ocfg{'oss2.primpos'}]) { $new{$f} = $hash{$f}; push(@{$chged{$key}}, $hash{$f},$scoutSA[$ocfg{'oss2.primpos'} +] ); } # ... }
I'm not sure how $scoutSA[$ocfg{'oss2.primpos'}] varies from $mcc to $mnc to the next variable and so on, so you'd need to incorporate a mapping in there for that too.
Some general observations about your code:
I've made these assumptions and included them in my example above. If I'm way off base, let me know.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parsing/Comparing
by mrras25 (Acolyte) on Mar 10, 2006 at 20:23 UTC |