in reply to uninitialized value in modulus (%)
if ($alphabet{$s} % 2) {
The problem must be here somehow, becase you're using the % operator only here. The warning indicates that one operand of % is undefined. 2 is a defined constant, so $alphabet{$s} must be undef. %alphabet mus have been filled somehwere else, you didn't show that code, $s comes from a very "ugly" part of your code:
foreach $record (@contents) { # where does @contents come from? # you said a flat-file: why did you read the whole # file into an array, if you did? is that neccessary? # you'll probably rather like while(defined(my $record = <$flatfilehandle>)){ @fields = split(/\|/,$record); # @fields is global? probably not my @fields = split... $tidm=$fields[0];$tidm=~s/\s+$//g; $nice=$fields[1];$nice=~s/\s+$//g; #it's much easier to say my ($tidm,$nice) = split /\|/,$record; # and it's more effective to drop the /g, for it's # completely useless: You cannot mach the EOString more # than one time. Correct me if these variables might # contain multiple lines, but i'm "quite sure" they don't # :) $s = substr($nice,0,1);
So now $s holds the first character of $nice. If $nice is empty, $s will be empty, too. Do you have the key '' in your hash %alphabet. $s may be any character (apart from '') depending on the input, are all cases covered in %alphabet? If not, consider assuming a default:
--(defined $alphabet{$s} ? $alphabet{$s} : 0) % 2 # use exists() if all values of %alphabet are defined
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: uninitialized value in modulus (%)
by alexiskb (Acolyte) on Aug 19, 2002 at 14:49 UTC | |
by alexiskb (Acolyte) on Aug 21, 2002 at 07:43 UTC |