I'm actually working on that now :D Mathew
Roman wrote: > Wouldn't it be better to filter the result with the sql statement? Instead > of doing it in perl. > > > -----Original Message----- > From: Mathew Snyder [mailto:[EMAIL PROTECTED] > Sent: Thursday, 16 November 2006 4:53 PM > To: John W. Krahn > Cc: Perl Beginners > Subject: Re: Database entries into a hash or array > > Ah-hah, of course! Thanks. > > Mathew > > John W. Krahn wrote: >> Mathew Snyder wrote: >>> Figured it out. >>> >>> New question though. Here's my code: >>> >>> #!/usr/bin/perl >>> use DBI; >>> use strict; >>> >>> my $dbh = DBI->connect ( "dbi:mysql:dbname=rt3_devel;host=10.0.2.27", >>> "svr", "XXXXXXXX") or die "Cannot connect to database!\n"; >>> >>> my $sth = $dbh->prepare("SELECT DISTINCT Content FROM >>> ObjectCustomFieldValues") or die "Cannot prepare statement: > $DBI::errstr\n"; >>> $sth->execute; >>> >>> my @profiles; >>> while (my $profile = $sth->fetchrow()){ >>> # next if $profile = "Routine"; >>> # next if $profile = "Normal"; >>> # next if $profile = "Unusual"; >>> push(@profiles, $profile); >>> } >>> >>> foreach (@profiles){ print $_ . "\n" }; >>> >>> $sth->finish; >>> >>> >>> I need to skip three items in the database and not have them placed in >>> the array. However, if I use next such as the lines commented out above >>> I get no output whatsoever. Even uncommenting one gives me nothing. >>> How do I tell the script to discard the three items but continue to >>> populate the database with everything else? >> You are using the assignment operator (=) so $profile is always true. You >> need to use a string comparison operator instead: >> >> next if $profile eq 'Routine'; >> next if $profile eq 'Normal'; >> next if $profile eq 'Unusual'; >> >> >> >> John > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>