[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-Forum] Problem with checking existence in a hash.



Hi, I have the following subroutine, and It used to work perfectly, but
al of a sudden it doesn't work at all. And I cant get it to work I try
all different versions. 
Among others I've tried the following:
unless (exists($is_kurskod{$some_code}))

I'm on a G4, WebSTAR 4,2 (if that's relevant).

Grateful for any help.
// Jimmy Lantz @Lund University @  Sweden @Earth.
What's wrong:
############### For pseudo code see below. ####

sub do_omreg
{
$omregfil = 'Server G4:DATABAS:data:omreg.data';
&KursModul::read_file($omregfil);
@omregfil = @KursModul::lines;
undef %is_kurskod;
for (@omregfil) { $is_kurskod{$_} = 1 }

@omregkoder = split(/ /,$in{'omreg'});

foreach $some_code (@omregkoder)
{
unless ($is_kurskod{$some_code} = 1) #Is this my problem ??
{
$fel = 'ja';
$omregfel = 'ja';
push (@fel_omreg_kod, $some_code);
}
}

}

###########Pseudo-code:
This sub is supposed to:
Set the variable $omregfil to a file path.
Use a read routine from a module 
Set the result to @omregfil.
the assign every value in the array to a hash and set the hash value to 1.
then split the value from form input to the array @omregkoder
then handle each of the values in the array @omregkoder
and unless the value exist in the hash %is_kurskod then do some variable
assignments and then push that value into another array.

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-forum-request@macperl.org