On Thu, 8 Jul 2004, Jordy Keighan wrote:
> Subject: Perl newbie please help
This is a very unhelpful subject. In the future, you should try to use a
subject that actually describes your problem. In this case, perhaps
"URI->new() hanging" or something similar.
> I am trying to compose a URI with some values that I get
> from parsing a XML string.
>
> If I print $user_array[0] ===> value = 'bob'
> but if I us it in URI->new( ... $user_array[0] ... ) the program
> hangs.
>
> If I manualy put 'bob' in $user_array[0]
> all is good and the URI->new( ... $user_array[0] ... ) statement
> works.
>
> Wy can't I use the string I got from my XML parsing ???
>
> Here is my code:
>
> my $user_string = "";
> my $parser = XML:
OM:
arser->new();
> my $doc = $parser->parse($xml);
> foreach my $key ($doc->getElementsByTagName('credentials')){
> $user_string = $user_string . $key->getAttribute('name') .
> " ";
> }
> @user_array = split(" ", $user_string);
Why are you doing this? Why are you composing one large string, manually
separating each field with spaces, and then using split to get an array
back out? Unless you're using $user_string later in unshown code (and if
you are, feel free to ignore me here), conider changing this to:
my @user_array;
foreach my $key ($doc->getElementsByTagName('credentials')){
push @user_array, $key->getAttribute('name');
}
> print $user_array[0]; # VALUE OK prints bob!!!!
out of curiousity, does it really print *just* bob? Or does the value
perhaps have extra whitespace attached to either end? What does this
print?
print "'$user_array[0]'\n";
>
>
> my $uri = URI->new("https://" . $ENV{HTTP_HOST} .
> /cgi-bin/dacs/dacs_group.cgi?OPERATION=LIST_GROUP_MEMBERSHIP&MEM BER_NAME="
There's a problem here. You're missing a double-quote. That should be a
syntax error. This leads me to believe you have not shown us your actual
code, but have instead re-typed it into this post. That's a Bad Thing.
Please make sure you copy and paste the actual text, so we can verify
we're looking at exactly what you're lookin gat.
> . $ENV{DACS_ACS_JURISDICTION} . ":" . $user_array[0].
> "&JURISDICTION=CUBEWERX&DACS_VERSION=1.2&FORMAT=xm l"); # STATEMENT
> HANGS !!!!
>
What exactly do you mean by "hangs"? If you put a print statement
immediately after this line, like:
print "debuggin!\n";
does this line not get printed?
Paul Lalli