jonnyfolk has asked for the wisdom of the Perl Monks concerning the following question:
depending on the results of the comparison I want one of two things to happen. I have worked out the expressions for each event but I have not been able to turn the two into a single conditional. I have been getting confused by the fact that the first expression hasmy @db = (1, 3, 5, 7, 9, 11); my @in = (1, 2, 5, 8, 9, 10, 13);
and the other is reversed:@lookup{@in} = ();
The two expressions are as follows:@lookup1{@db} = ();
and:my %lookup; @lookup{@in} = (); foreach my $elem (@db) { if (exists $lookup{$elem}) { @db = grep {not exists $lookup{$_}} @db; } }
If someone could kindly help me to do an if...elsif or whatever else to trigger one if the other is not true I would be very grateful.@lookup{@db} = (); foreach my $elem (@in) { if (not exists $lookup{$elem}) { push(@db, $elem); } }
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help needed to make a conditional statement
by djantzen (Priest) on Dec 04, 2002 at 03:42 UTC | |
by jonnyfolk (Vicar) on Dec 04, 2002 at 16:42 UTC | |
by djantzen (Priest) on Dec 04, 2002 at 19:28 UTC | |
by jonnyfolk (Vicar) on Dec 04, 2002 at 20:11 UTC | |
by djantzen (Priest) on Dec 05, 2002 at 00:05 UTC | |
by jonnyfolk (Vicar) on Dec 04, 2002 at 21:38 UTC | |
|
Re: Help needed to make a conditional statement
by Anonymous Monk on Dec 05, 2002 at 08:17 UTC | |
by Anonymous Monk on Dec 05, 2002 at 08:30 UTC | |
by jonnyfolk (Vicar) on Dec 05, 2002 at 15:56 UTC |