[28140] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9504 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 20 18:10:17 2006

Date: Thu, 20 Jul 2006 15:10:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 20 Jul 2006     Volume: 10 Number: 9504

Today's topics:
    Re: Question on comparing to variables containing integ <"v.niekerk at hccnet.nl">
    Re: Question on comparing to variables containing integ <David.Squire@no.spam.from.here.au>
    Re: Question on comparing to variables containing integ <"v.niekerk at hccnet.nl">
    Re: Question on comparing to variables containing integ <David.Squire@no.spam.from.here.au>
    Re: Question on comparing to variables containing integ <David.Squire@no.spam.from.here.au>
    Re: Question on comparing to variables containing integ <David.Squire@no.spam.from.here.au>
    Re: Question on comparing to variables containing integ <mritty@gmail.com>
    Re: Question on comparing to variables containing integ <tadmc@augustmail.com>
        SOAP::Lite and complex client call parameter <info@randspringer.de>
        subroutine <weberw@adelphia.net>
    Re: subroutine usenet@DavidFilmer.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 20 Jul 2006 21:32:50 +0200
From: Huub <"v.niekerk at hccnet.nl">
Subject: Re: Question on comparing to variables containing integers
Message-Id: <44bfda63$0$6483$e4fe514c@dreader30.news.xs4all.nl>


> 
> If you want the value of the 1st element instead of the number of
> elements then don't stomp over the value of the 1st element with
> the number of elements.
> 
> 
>> Thanks for helping out (hint/clue/link),
> 
> 
>    if ($betaald[0] == $vergelijk) {..code..}   # if numbers
> 
>    if ($betaald[0] eq $vergelijk) {..code..}   # if strings
> 
> 

I have made an error in posting. I'm sorry for that. In the comparison 
of strings I do use "eq". The rest of the code is the same. Due to my 
error some assumptions and solutions given by you and the others are 
possibly not accurate.
You are talking about stomp/not stomp. In CPAN search, I can't find 
this. Could you explain/be more specific?

Thank you

Huub


------------------------------

Date: Thu, 20 Jul 2006 20:37:59 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Question on comparing to variables containing integers
Message-Id: <e9om2n$55m$1@gemini.csx.cam.ac.uk>

Huub wrote:
> 
>>
>> If you want the value of the 1st element instead of the number of
>> elements then don't stomp over the value of the 1st element with
>> the number of elements.
>>
>>
>>> Thanks for helping out (hint/clue/link),
>>
>>
>>    if ($betaald[0] == $vergelijk) {..code..}   # if numbers
>>
>>    if ($betaald[0] eq $vergelijk) {..code..}   # if strings
>>
>>
> 
> I have made an error in posting. I'm sorry for that. 

 ... and the lesson is: never ever type code into your post. Only ever 
cut and paste from an actual script you have tested.

In the comparison
> of strings I do use "eq". The rest of the code is the same. Due to my 
> error some assumptions and solutions given by you and the others are 
> possibly not accurate.
> You are talking about stomp/not stomp. In CPAN search, I can't find 
> this. Could you explain/be more specific?
> 

"stomp" has nothing to do with Perl. It's English, meaning "to step on 
heavily". Tad meant (as I also said) that you had overwritten the value 
in the first position of the array @betaald, which is almost certainly 
the value you were actually interested in.


DS


------------------------------

Date: Thu, 20 Jul 2006 21:50:11 +0200
From: Huub <"v.niekerk at hccnet.nl">
Subject: Re: Question on comparing to variables containing integers
Message-Id: <44bfde62$0$18708$e4fe514c@dreader28.news.xs4all.nl>

> 
> "stomp" has nothing to do with Perl. It's English, meaning "to step on 
> heavily". Tad meant (as I also said) that you had overwritten the value 
> in the first position of the array @betaald, which is almost certainly 
> the value you were actually interested in.
> 
>

Tad suggested that I'd put print statements in between to actually see 
the values. I already did that, which is how I discovered this way 
apparently doesn't work for numbers.
How can I overwrite the value of the first position of @betaald, if I do 
$betaald[0] = @betaald? This overwrites the first position of $betaald.
If @betaald has the correct value, and the rest of my code doesn't work 
for numbers, how can I get that value into $betaald? I can't do "if 
(@betaald == @vergelijk) {}".

Thanks,

Huub


------------------------------

Date: Thu, 20 Jul 2006 20:56:10 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Question on comparing to variables containing integers
Message-Id: <e9on4q$7gn$1@gemini.csx.cam.ac.uk>

Huub wrote:
> 
> Tad suggested that I'd put print statements in between to actually see 
> the values. I already did that, which is how I discovered this way 
> apparently doesn't work for numbers.
> How can I overwrite the value of the first position of @betaald, if I do 
> $betaald[0] = @betaald? This overwrites the first position of $betaald.
> If @betaald has the correct value, and the rest of my code doesn't work 
> for numbers, how can I get that value into $betaald? 

You don't need to. You can just use that element of the array directly 
(also as I suggested. Did you even read my response??)

I can't do "if
> (@betaald == @vergelijk) {}".


But you can do:

if ($betaald[0] = @vergelijk) {...}

Do this straight after the fetch_rowarray (ideally checking that there 
is actually some data there first). All the assignments you were doing 
in between are superfluous.

I suspect you need to read up on how to use arrays in Perl. See perldoc 
perldata.


DS


------------------------------

Date: Thu, 20 Jul 2006 20:57:03 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Question on comparing to variables containing integers
Message-Id: <e9on6f$7gn$2@gemini.csx.cam.ac.uk>

David Squire wrote:
> 
> 
> But you can do:
> 
> if ($betaald[0] = @vergelijk) {...}

Whoops! Should be:

if ($betaald[0] == @vergelijk) {...}


------------------------------

Date: Thu, 20 Jul 2006 20:58:22 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
To: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Question on comparing to variables containing integers
Message-Id: <44BFE05E.6070809@no.spam.from.here.au>

David Squire wrote:
> David Squire wrote:
>>
>>
>> But you can do:
>>
>> if ($betaald[0] = @vergelijk) {...}
> 
> Whoops! Should be:
> 
> if ($betaald[0] == @vergelijk) {...}

Arghh. Just noticed the second part of what you had written. In the 
example from earlier today you had $vergelijk, a scalar. Now you have 
@vergelijk, an array. Which do you actually mean?


DS


------------------------------

Date: 20 Jul 2006 13:21:29 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Question on comparing to variables containing integers
Message-Id: <1153426889.613554.294260@i42g2000cwa.googlegroups.com>

Huub wrote:
> >
> > "stomp" has nothing to do with Perl. It's English, meaning "to step on
> > heavily". Tad meant (as I also said) that you had overwritten the value
> > in the first position of the array @betaald, which is almost certainly
> > the value you were actually interested in.
>
> Tad suggested that I'd put print statements in between to actually see
> the values. I already did that, which is how I discovered this way
> apparently doesn't work for numbers.

What "way" of doing *what* doesn't work for numbers?

> How can I overwrite the value of the first position of @betaald, if I do
> $betaald[0] = @betaald?

This question is non-sensical.  That line of code *does* overwrite the
first position of @betaald.  It puts the size of @betaald into the
first position of @betaald.

> This overwrites the first position of $betaald.

This statement is also nonsensical.  First, you have, until now, not
mentioned any such variable $betaald.  We've been dealing with an array
@betaald.  $betaald is a scalar variable.  There is no such thing as
its "first position".  Even assuming that was just a typo, isn't that
exactly what you just asked how to do?

> If @betaald has the correct value, and the rest of my code doesn't work
> for numbers,

More nonsense.  @betaald does not have a "correct value".  @betaald is
an array, and therefore has a list of values.

Again, what "doesn't work for numbers"?

>  how can I get that value into $betaald?

Get *what* value into $betaald?!   Please read your post before you
post it.  This is almost entirely gibberish.

> I can't do "if (@betaald == @vergelijk) {}".

Of course you *can* do that... that compares the sizes of the two
arrays @betaald and @vergelijk.  If the sizes are equal, the if block
is executed.  If not, the if block is skipped.  Is that what you want
to happen?

NO WHERE in this post have you said what you actually *want* to do, nor
*why* you want to do it.

I believe, however, that you have a major misconception about the way
scalar and array variables work in Perl.  Allow me to attempt to
explain:

* @betaald is an array variable.  It contains a list of values.
* $betaald is a scalar variable.  It contains one single value.
* @betaald and $betaald have *NOTHING TO DO WITH EACH OTHER*.  They are
completely un-related.  Changing @betaald has no effect on $betaald,
nor vice versa.
* To access a certain element in @betaald, you append square-brackets
with the index number between them, and replace the @ with a $.
Therefore, $betaald[0] is the first element of @betaald.  $betaald[1]
is the second element, etc.
* Again, $betaald[0] has NOTHING to do with $betaald.  The first is an
element of the array @betaald, and the second is an unrelated scalar
variable.
* When you use a Perl array in scalar context (ex, comparing it to a
scalar, or assigning it to a scalar), it returns the size of that
array.  For example, $foo = @betaald; assigns $foo to have the size of
@betaald.  `if ($bar == @betaald) { } ` checks to see if $bar's value
is the same as the size of @betaald.
* Because elements of an array are themselves scalars, assigning to a
specific element of an array imposes scalar context.  If I had an array
@stuff, and I said $stuff[0] = @betaald, that would assign the size of
@betaald to be the first element of @stuff.  Likewise, saying
$betaald[0] = @betaald assigns the first element of @betaald to be the
size of @betaald (thus replacing whatever was already there)

I hope that helps to clarify Perl's arrays for you, so that you can
better express to us what it is you're actually *trying* to accomplish.

Paul Lalli



------------------------------

Date: Thu, 20 Jul 2006 15:42:50 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Question on comparing to variables containing integers
Message-Id: <slrnebvqma.fe1.tadmc@magna.augustmail.com>

Huub <> wrote:


[ Please provide a proper attribution in your followups. ]
  

>>    if ($betaald[0] == $vergelijk) {..code..}   # if numbers
>> 
>>    if ($betaald[0] eq $vergelijk) {..code..}   # if strings

> I have made an error in posting. 


Yet again.


> I'm sorry for that. 


Sure you are.


> Due to my 
> error some assumptions and solutions given by you and the others are 
> possibly not accurate.


Yes, so we were all wasting our time trying to help you then.


> You are talking about stomp/not stomp.
> Could you explain/be more specific?


Yes I could.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Thu, 20 Jul 2006 21:37:08 +0200
From: gelbeiche <info@randspringer.de>
Subject: SOAP::Lite and complex client call parameter
Message-Id: <20060720213708.54734feb@redrat.quark.de>

Hi,

I use SOAP::Lite for a client to call some Java-based webservices.
All is fine as long as the signature of the webservice use simple
parameters.
But now I have to call a webservice which has an parameter that is an
array of complex data (in C I would say an array of structs, in Java
it is called array of valueobjects).
Actually it is an order with some order details. The raw XML-picture
would look like:
<order>
 <customernumber>1</customernumber>
 <company>2</company>
 <orderdetails>
   <orderdetail>
      <...> //some order detail data here
   <orderdetail>
   <orderdetail>
      <...> //some order detail data here
   <orderdetail>
 </orderdetails>
</order>

The customernumber and company are simple data types,
the orderdetails are an array of orderdetail.

I tried the following:
my $soap_response = SOAP::Lite
   -> proxy($webservice_address)
   -> uri($uri)
   ->
receiveOrder(SOAP::Data->type(string=>"my_externelCustNo")->name('string'),
                   SOAP::Data->type(string=>"my_externalOrderNo")->name('string0'),
                   SOAP::Data->type(byte=>1)->name('byteVal'),
                   SOAP::Data->type(byte=>2)->name('byteVal0'),
                   SOAP::Data->type(byte=>3)->name('byteVal1'),
                   SOAP::Data->name(orderDetailVOs=>"<orderDetailVOs
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:n1=\"java:valueobjects.shared.online\"
soapenc:arrayType=\"n1:OrderDetailVO[1]\">
<OrderDetailVO   xsi:type=\"n1:OrderDetailVO\">
<comunicatedDeliveryType
xsi:type=\"xsd:byte\">1</comunicatedDeliveryType>  <confirmationID
href=\"#ID_4\">  </confirmationID>  
<itemNumber xsi:type=\"xsd:int\">100</itemNumber>  
<orderType xsi:type=\"xsd:byte\">1</orderType>  
<paymentCondition href=\"#ID_4\">  </paymentCondition>  
<promotion href=\"#ID_4\"></promotion>  
<quantity xsi:type=\"xsd:int\">100</quantity>
<sellingPrice xsi:type=\"xsd:int\">100</sellingPrice>  
<size href=\"#ID_4\">  </size> 
</OrderDetailVO> <xsd:string xsi:type=\"xsd:string\"
id=\"ID_4\">sample string</xsd:string>
</orderDetailVOs>"));

When I call the webservice I get no error. When I look at the webservice
server side I see that the simple data are properly transmitted to the
server but the data in the XML structure are not.
The method at Java side which is called has a signature:

int receiveOrder(String extCustNo, String
extOrderNo, ...,OrderDetailVO[] orderDetails);

and when I access the orderDetails-array it contains no values.

What I'm doing wrong and where can I find an client example which uses
arrays of data structures ?

Thomas











------------------------------

Date: 20 Jul 2006 14:36:14 -0700
From: "weberw@adelphia.net" <weberw@adelphia.net>
Subject: subroutine
Message-Id: <1153431374.084648.21860@i42g2000cwa.googlegroups.com>

I am trying to incorprate a subroutine to perform an extra calculation
on overtime hours and am not sure how to add this part to the code.
$OT = &calculateOT(emp_hours);

  & search_page();


	my $p_lname = param('lname');
	my $p_fname = param('fname');

  open (THIS, "< $ENV{'SCRIPT_FILENAME'}") || die "couldn't open script
file\n";
  while (<THIS>) { $script .= "$.\t$_" }
  close (THIS);
  $script = escapeHTML($script);
 my $dbh = DBI->connect("DBI:mysql:database=thename;host=whatever", "",
"", {'RaiseError' => 1}) or die "Failed to connect: $!";

  my $sth = $dbh->prepare("SELECT * FROM employee WHERE emp_lname= ? or
emp_fname= ?") or die "Failed to prepare: $!";
  my @rows = th("Employee ID").th("Last Name").th("First
Name").th("Wage").th("Hours");
  $sth->execute ($p_lname,$p_fname) or die "Failed to execute: $!";




  while ( my @elements = $sth->fetchrow() ) {

	#call a subroutine that calculates the number of OT hours
	$OT = &calculateOT(emp_hours);

      my $output;
      for (@elements) { $output .= td($_) }
      push @rows, $output."\n";
  }
  $dbh->disconnect or die "Failed to disconnect: $!";

  print header,
      start_html("Employee List"),
      a( {-href=>'emp1.cgi'}, h2("Employee List") ),
      table ( {-border=>'1'}, Tr(\@rows) ),
      hr, pre($script),
      end_html;



sub search_page {
		print header,
			start_html("Employee Search Form"),
			h2("Employee Search Form"),
			start_form,
			"First Name: ",
			textfield(-name=>'fname'),
			br,
			"Last Name: ",
			textfield(-name=>'lname'),
			br,
			submit(-label=>'Search'),
			end_form,
			hr,
			end_html;
	}

sub calculateOT{
	if	(emp_hours > 40){
	$OT =  emp_hours-40;
}
else{
	$OT = 0;
	}
		 end_html;



------------------------------

Date: 20 Jul 2006 15:00:45 -0700
From: usenet@DavidFilmer.com
Subject: Re: subroutine
Message-Id: <1153432845.843776.303160@i3g2000cwc.googlegroups.com>

weberw@adelphia.net wrote:
[ a multi-posted question ]

Please do not multi-post. That is considered very rude in Usenet.

-- 
David Filmer (http://DavidFilmer.com)



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 9504
***************************************


home help back first fref pref prev next nref lref last post