vsailas has asked for the wisdom of the Perl Monks concerning the following question:
if( $update eq 1) { my $sth= $dbh->prepare("select ip_start, ip_end from ip_range wher +e subscription_no =?"); $sth->execute($subno); my @row; while (@row = $sth->fetchrow_array()) { my($start, $stop)= @row ; $startId=$start; $start=~ s/\.//gi; $stop=~ s/\.//gi; if (($begin1 >= $start) && ($end1 =< $stop)) { $ipFlag=1; } } $sth->finish(); } else { ### insert into table, the fresh data. $host="you"; my $sth = $dbh->prepare("insert into ip_range(subscription_no, ip_ +start, ip_end, hostname, creator, creationdate) values(?,?,?,?,?,now( +))"); $sth->execute($subno, $begin, $end, $host, $creator); $sth->finish(); } # update only Creator since ip already exist. if( $ipFlag eq 1) { my $sth= $dbh->prepare("update ip_range set hostname=?, creator=? +where subscription_no =?"); $sth->execute($host, $creator, $subno); $sth->finish(); } ### insert into table, the fresh data. else { $host="me"; my $sth = $dbh->prepare("insert into ip_range(subscription_no, ip_ +start, ip_end, hostname, creator, creationdate) values(?,?,?,?,?,now())"); $sth->execute($subno, $begin, $end, $host, $creator); $sth->finish(); } $dbh->disconnect();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Please help me with this conditional loop on text entries.
by poolpi (Hermit) on Dec 14, 2007 at 08:55 UTC | |
by vsailas (Beadle) on Dec 14, 2007 at 10:03 UTC | |
|
Re: Please help me with this conditional loop on text entries.
by lidden (Curate) on Dec 14, 2007 at 07:03 UTC | |
by tachyon-II (Chaplain) on Dec 14, 2007 at 07:55 UTC |