in reply to Re: Help needed to make a conditional statement
in thread Help needed to make a conditional statement
That does what I need when strings match. However when strings don't match the db is unchanged from the original, wheras I need the contents of @in pushed into @db:#!/usr/bin/perl -w #use strict; use CGI ':standard'; my @db = (1, 3, 5, 7, 9, 11); my @in = (1, 2, 5, 8, 9, 10, 13); my $var = 7; # I have this variable available to indicate the length o +f the array my (%db_lookup, %in_lookup); @db_lookup{@db} = (); @in_lookup{@in} = (); $count = 0; while ($count < $var) { if (exists $in_lookup{$count}, @db) { @db = grep { not exists $in_lookup{$_} } @db; $count += 1; } elsif (not exists $in_lookup{$count}, @db) { push @db, grep { not exists $db_lookup{$_} } @in; $count += 1; } } print "view: @db";
Where am I going wrong?my @db = (1, 3, 5, 7, 9, 11); my @in = (21, 22, 25, 28, 29, 210, 213);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Help needed to make a conditional statement
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 | |
|
Re: Re: Re: Help needed to make a conditional statement
by jonnyfolk (Vicar) on Dec 04, 2002 at 21:38 UTC |