When the user first comes to the page the first "IF" with x1a.html page loads, it makes the call to the "got_send()" no problem.
Once the user is on that first page they see buttons where they can click on it to get the other results, that's how the
other "IFs" get called/executed.
As you can see this sample program make calls and gets back some kind of XML, it is not XML it just looks like XML.
In this XML its where
I go through to get the values I need and to populate a html page for the user.
My issue is that I was asked to combined all the 3 calls at once and load as the user arrives on the first page.
How could I do that since the XML from each call comes in using the same XML and depending on a call the values in any of the tag numbers
in the XML will be different, lets say if I am expecting the value from tag <7> on the first call to be TOM, how could I call
the second "IF", since it will be empty or not and on the third one it could be "MARY" or any other value.
Is this a case where dimensional
arrays come to play and than it will not matter if I am making 2, 3 or more calls to got_send() sub?
I'll probably have to hard code some of the parameters to make the calls since they are necessary to the got_send() sub.
I am trapped, any suggestions please!!
Here is the sample code I have to relate to my question.
if($page eq "x1a.html")
{
$re_type = "a2";
$Q = ($prod) ? 'a0' : 'a0';
$send=$sec.$account.$year.$view;
}
if($page eq "x22.html")
{
$re_type = "x2";
$Q = ($prod) ? 'p0' : 'w0';
$send=$sec.$account.$year.$view;
}
if ($page eq "y11.html") {
$req_type = "y1";
$Q = ($prod) ? 'p0' : 'w0';
$send=$sec.$account.$year.$view.$action;
}
if ($send) {
got_send();
}
sub got_send {
my $socket;
my $x = '';
my @read = ();
my $host = ($prod) ? 'my.prod.com' : 'mytest.box.com';
my $port;
# Alternate depending on the time (in seconds)
($now[5] % 2) ? ($port = 6000) : ($port = 6100);
$AoH{300} = sprintf "%2s(%d) %s", $QPro, ($port/100), $send;
$socket = IO::Socket::INET->new( "$host:$port" ) or &error;
print $socket "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n
<!DOCTYPE ACCOUNTS REF NAMES>\n
<ACCOUNTS>\n
<Type>$re_type<Type>\n
<Id>$send</Id>\n
<Profile>$Q</Profile>
</ACCOUNTS>\n
\n";
$x = <$socket>;
close(Server);
$x=~s/</\n</g;
@read = split(/\n/, $x);
foreach my $y (@read)
{
if (!$y) { $y = '<0>' } # Prevent uninitialzed message on $1
$y=~/<(.*?)>(.*)/;
if($1 eq "7"){$name = $2;}
#more code here....
last if ($x =~ /^[\s\x00]*$/);
}
} #End of sub
Returned result from first call
<1>66543
<2>2009
<3>TY
<4>-
<6>
<7>TOM
<8>2 - DUNDAS
<8>100 - MAIN
<9>ONT 00001
<10>
<11>000-000-0000
<12>
I need some way to return multiple results and be able to differentiate
the tag values coming in in the same tag number to display:
<1>66543
<2>2009
<3>TY
<4>-
<6>
<7>TOM
<8>2 - DUNDAS
<8>100 - MAIN
<9>ONT 00001
<10>
<11>000-000-0000
<12>
<1>12345
<2>1999
<3>PP
<4>XLX - TEST
<6>Comm
<7>
<8>1 BLVD
<9>MA 00001
<10>CITI, INC.
<11>000-000-0000
<12>
<1>8887
<2>2000
<3>
<4>TEST
<6>
<7>JOE
<7>MARY
<8>100 MAIN
<9>CT 02221
<10>BH, INC.
<11>871-000-0000
<12>YEAR
Thanks for the help!!!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.