Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Monks, I have code which generates a large XML packet (containing hundreds of packet_refs, see below) based on the result of a SQL query. I want to break this down so that 1 XML packet, each containing 10 packet_ref's is sent, then looped for the rest of the results. I've tried to adapt my code to do this, but I don't know what the condition should be for the if statement. As requested, this is a cut down example of my code. Please advise
foreach my $item (@SQLvars){ my $sth = $self->dbh()->prepare($DocumentQuery) or die "Can't prepair statement: $self->DBI::errstr"; my ( $foo, $bar ); $sth->execute( $item->{PACKID}, $item->{PACKINFO} ); $sth->bind_columns(\( $foo, $bar )); while ($sth->fetch) { $XMLContent .= "<packet_ref> <packID>$foo</packID> <packInfo>$bar</packINFO> </packet_ref>\n"; if (){ # if there are 10 packet_ref's send the XML and loop round + for the remainder my $XMLPacket; $XMLPacket = $XMLHead . $XMLContent . $XMLFoot; my $mech = WWW::Mechanize->new(); $mech->get( $TargetURL ); $mech->field( "xml_doc", $XMLPacket ); my $mechres = $mech->submit(); if ($mechres->is_success) { warn $mechres->decoded_content; return "Success"; }else{ warn $mechres->status_line, "\n"; return "Error"; } undef $XMLContent; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Dynamically breaking up a data set
by choroba (Cardinal) on May 23, 2012 at 12:02 UTC | |
by Anonymous Monk on May 23, 2012 at 12:22 UTC | |
by choroba (Cardinal) on May 23, 2012 at 12:32 UTC | |
by Anonymous Monk on May 23, 2012 at 14:34 UTC | |
|
Re: Dynamically breaking up a data set
by Anonymous Monk on May 23, 2012 at 12:02 UTC | |
|
Re: Dynamically breaking up a data set
by locked_user sundialsvc4 (Abbot) on May 23, 2012 at 12:47 UTC | |
by Jenda (Abbot) on May 24, 2012 at 08:17 UTC |