[26608] in Perl-Users-Digest
Perl-Users Digest, Issue: 8720 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 1 21:21:21 2005
Date: Thu, 1 Dec 2005 18:21:15 -0800 (PST)
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, 1 Dec 2005 Volume: 10 Number: 8720
Today's topics:
Whats the reason for this?? <recker_us@yahoo.com>
Re: Whats the reason for this?? (Anno Siegel)
Re: Whats the reason for this?? <someone@example.com>
Re: Whats the reason for this?? (Anno Siegel)
Re: Whats the reason for this?? <sdn.girths00869@zoemail.net>
Re: Whats the reason for this?? <jurgenex@hotmail.com>
Re: Whats the reason for this?? <tadmc@augustmail.com>
Re: Whats the reason for this?? <bernard.el-haginDODGE_THIS@lido-tech.net>
Re: Whats the reason for this?? <xx087@freenet.carleton.ca>
Re: Whats the reason for this?? <abigail@abigail.nl>
Win32::SqlServer 2.001 <esquel@sommarskog.se>
Re: XML::Simple array size robic0
Re: XML::Simple array size robic0
Re: XML::Simple array size <daveandniki@ntlworld.com>
Re: XML::Simple array size robic0
Re: XML::Simple array size robic0
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 01 Dec 2005 16:33:29 +0530
From: JP <recker_us@yahoo.com>
Subject: Whats the reason for this??
Message-Id: <z0Bjf.8$MC6.52@news.oracle.com>
perl -e '1+1+1'
The answer is 3.
but
perl -e 'print (1+1)+1'
thje answer in this case is 2.
Any explination why I get geting a different value in the second case??
Thanks,
JP
------------------------------
Date: 1 Dec 2005 11:09:52 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Whats the reason for this??
Message-Id: <dmmlm0$gib$1@mamenchi.zrz.TU-Berlin.DE>
JP <recker_us@yahoo.com> wrote in comp.lang.perl.misc:
> perl -e '1+1+1'
> The answer is 3.
>
> but
>
> perl -e 'print (1+1)+1'
>
> thje answer in this case is 2.
> Any explination why I get geting a different value in the second case??
Consult the documentation of the function you're using. In "perldoc
-f printf", note the sentence beginning "Also be careful..." near the
end.
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
Date: Thu, 01 Dec 2005 11:36:00 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Whats the reason for this??
Message-Id: <AeBjf.142580$yS6.40545@clgrps12>
Anno Siegel wrote:
> JP <recker_us@yahoo.com> wrote in comp.lang.perl.misc:
>>perl -e '1+1+1'
>>The answer is 3.
>>
>>but
>>
>>perl -e 'print (1+1)+1'
>>
>>thje answer in this case is 2.
>>Any explination why I get geting a different value in the second case??
>
> Consult the documentation of the function you're using. In "perldoc
> -f printf", note the sentence beginning "Also be careful..." near the
> end.
The OP will probably find that sentence easier using "perldoc -f print".
:-)
John
--
use Perl;
program
fulfillment
------------------------------
Date: 1 Dec 2005 11:37:58 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Whats the reason for this??
Message-Id: <dmmnam$hnn$2@mamenchi.zrz.TU-Berlin.DE>
John W. Krahn <krahnj@telus.net> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > JP <recker_us@yahoo.com> wrote in comp.lang.perl.misc:
> >>perl -e '1+1+1'
> >>The answer is 3.
> >>
> >>but
> >>
> >>perl -e 'print (1+1)+1'
> >>
> >>thje answer in this case is 2.
> >>Any explination why I get geting a different value in the second case??
> >
> > Consult the documentation of the function you're using. In "perldoc
> > -f printf", note the sentence beginning "Also be careful..." near the
> > end.
>
> The OP will probably find that sentence easier using "perldoc -f print".
Oh my. Where did that "f" come from?
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
Date: Thu, 01 Dec 2005 06:09:51 -0600
From: "Eric J. Roode" <sdn.girths00869@zoemail.net>
Subject: Re: Whats the reason for this??
Message-Id: <Xns971F4922F9347sdn.comcast@216.196.97.136>
JP <recker_us@yahoo.com> wrote in news:z0Bjf.8$MC6.52@news.oracle.com:
> perl -e '1+1+1'
> The answer is 3.
>
> but
>
> perl -e 'print (1+1)+1'
>
> thje answer in this case is 2.
> Any explination why I get geting a different value in the second
> case??
For Perl operators like print, the rule is "If it LOOKS like a function
call, it BEHAVES like a function call."
--
Eric
`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++
;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`
------------------------------
Date: Thu, 01 Dec 2005 12:18:20 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Whats the reason for this??
Message-Id: <gSBjf.2557$wD4.2052@trnddc02>
JP wrote:
> perl -e '1+1+1'
> The answer is 3.
>
> but
>
> perl -e 'print (1+1)+1'
>
> thje answer in this case is 2.
> Any explination why I get geting a different value in the second case??
Maybe because (1+1) is 2?
jue
------------------------------
Date: Thu, 1 Dec 2005 06:15:08 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Whats the reason for this??
Message-Id: <slrndotqac.c2e.tadmc@magna.augustmail.com>
JP <recker_us@yahoo.com> wrote:
> perl -e '1+1+1'
> The answer is 3.
>
> but
>
> perl -e 'print (1+1)+1'
>
> thje answer in this case is 2.
Try it with warnings enabled:
perl -we 'print (1+1)+1'
> Any explination why I get geting a different value in the second case??
Message-Id: <slrnatq036.2q2.tadmc@magna.augustmail.com>
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 1 Dec 2005 14:21:20 +0100
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Whats the reason for this??
Message-Id: <Xns971F9208DDDA6elhber1lidotechnet@10.232.40.227>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
[...]
>> > Consult the documentation of the function you're using. In
>> > "perldoc -f printf", note the sentence beginning "Also be
>> > careful..." near the end.
>>
>> The OP will probably find that sentence easier using "perldoc -f
>> print".
>
> Oh my. Where did that "f" come from?
print lc $1 if 'Freudian slip' =~ m/(.)/;
--
Cheers,
Bernard
------------------------------
Date: 1 Dec 2005 17:03:35 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: Whats the reason for this??
Message-Id: <slrndoub78.f6g.xx087@smeagol.ncf.ca>
At 2005-12-01 06:03AM, JP <recker_us@yahoo.com> wrote:
> perl -e '1+1+1'
> The answer is 3.
>
> but
>
> perl -e 'print (1+1)+1'
>
> thje answer in this case is 2.
> Any explination why I get geting a different value in the second case??
This may shed some light on the destination of the "lost" "+1":
perl -le '$result = print(3+5)+10; print $result'
8
11
--
Glenn Jackman
Ulterior Designer
------------------------------
Date: 02 Dec 2005 00:07:26 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Whats the reason for this??
Message-Id: <slrndov41u.2q1.abigail@alexandra.abigail.nl>
Tad McClellan (tadmc@augustmail.com) wrote on MMMMCDLXXV September
MCMXCIII in <URL:news:slrndotqac.c2e.tadmc@magna.augustmail.com>:
`` JP <recker_us@yahoo.com> wrote:
`` > perl -e '1+1+1'
`` > The answer is 3.
`` >
`` > but
`` >
`` > perl -e 'print (1+1)+1'
`` >
`` > thje answer in this case is 2.
``
``
`` Try it with warnings enabled:
``
`` perl -we 'print (1+1)+1'
Yeah. But be sure to use one space, and exactly one space between
the print and the opening parenthesis. If you don't use a space, or
use two spaces, or a tab, the warning is disabled.
Also, if you make this mistake with, oh, say, 'abs' or 'log', you
will not get the warning. Not even if you use a single space.
But that's the worst thing about this warning. It's all the false
positives (all the cases where valid code triggers the warning)
that annoys the hell out of me. Enough to have turned it into a
(lightning) talk: http://perl.abigail.nl/Talks/IF/HTML/.
I always rip out this warning from the perl source before compiling it.
The alternative would be to disable warnings.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'
------------------------------
Date: Sun, 27 Nov 2005 17:09:28 GMT
From: Erland Sommarskog <esquel@sommarskog.se>
Subject: Win32::SqlServer 2.001
Message-Id: <IqqCs3.v46@zorch.sf-bay.org>
Two weeks ago I announced MSSQL::OlleDB 2.000. That name was not popular
with the people on the Perl module list (since the module is Windows-only),
so I've renamed the module to Win32::SqlServer and changed the version
number 2.001. I should add that this name much better describes the purpose
of the module. Here follows text from the original announcement, adapted to
the new name:
Despite the version number, this is actually a new module, but I versioned
it 2.001 as it it a successor to my older module MSSQL::Sqllib.
Win32::SqlServer is aimed to be the prime choice when you need to connect
to Microsoft SQL Server from Windows, and you do not have any requirement
to be portable to any other DB engine or platform. Win32::SqlServer uses the
OLE DB API to connect to SQL Server. With Win32::SqlServer you have access
to about all features in SQL Server 2005.
The module is on its way into CPAN. You can also download it from
http://www.sommarskog.se/mssqlperl/index.html.
--
Erland Sommarskog, Stockholm, esquel@sommarskog.se
------------------------------
Date: Mon, 28 Nov 2005 22:51:08 -0800
From: robic0
Subject: Re: XML::Simple array size
Message-Id: <g5uno11r6901vv00tnpln9r35j3q4v3jfc@4ax.com>
On Sat, 14 Feb 2004 17:58:08 -0500, Mark J Fenbers
<Mark.Fenbers@noaa.gov> wrote:
>In my sample XML file...
>
><main>
> <level1>
> <level2>whatever</level2>
> <level2>whatever</level2>
> <level2>whatever</level2>
> <level2>whatever</level2>
> <level2>whatever</level2>
> ...
> </level1>
></main>
>
>I have an variable number of level2 tags. Using XML::Simple, I can access the
>value of the 4th one by something like this:
>
> my $main = XMLin("myfile.xml");
> print $main->{level1}->{level2}->[3]->{content};
>
>But I really want to know how many level2 records there are. I tried variations
>
Hey isn't the "$main" name take already?
New rule, you have to give more details than "I want to count all
animals on Noah's ark". Noah didn't coun't them for a reason....
Unless you positively know ahead of time the structure of the xml
in question, you can't rely on xml::simple's output structure.
I guess thats the other question.....
------------------------------
Date: Mon, 28 Nov 2005 22:54:42 -0800
From: robic0
Subject: Re: XML::Simple array size
Message-Id: <oluno11vrd6f7qehjs5moap5llrdvg36l8@4ax.com>
On Mon, 28 Nov 2005 22:51:08 -0800, robic0 wrote:
>On Sat, 14 Feb 2004 17:58:08 -0500, Mark J Fenbers
><Mark.Fenbers@noaa.gov> wrote:
>
>>In my sample XML file...
>>
>><main>
>> <level1>
>> <level2>whatever</level2>
>> <level2>whatever</level2>
>> <level2>whatever</level2>
>> <level2>whatever</level2>
>> <level2>whatever</level2>
>> ...
>> </level1>
>></main>
>>
>>I have an variable number of level2 tags. Using XML::Simple, I can access the
>>value of the 4th one by something like this:
>>
>> my $main = XMLin("myfile.xml");
>> print $main->{level1}->{level2}->[3]->{content};
>>
>>But I really want to know how many level2 records there are. I tried variations
>>
>Hey isn't the "$main" name take already?
>New rule, you have to give more details than "I want to count all
>animals on Noah's ark". Noah didn't coun't them for a reason....
>Unless you positively know ahead of time the structure of the xml
>in question, you can't rely on xml::simple's output structure.
>I guess thats the other question.....
Would you know that its simple xml and not nested content?
Are you analyzing unknown xml structure?
Did you write this xml structure that you want to analyze?
------------------------------
Date: Tue, 29 Nov 2005 14:01:02 +0100
From: "Dave" <daveandniki@ntlworld.com>
Subject: Re: XML::Simple array size
Message-Id: <438c5115$0$20172$8fcfb975@news.wanadoo.fr>
<robic0> wrote in message news:g5uno11r6901vv00tnpln9r35j3q4v3jfc@4ax.com...
> On Sat, 14 Feb 2004 17:58:08 -0500, Mark J Fenbers
> <Mark.Fenbers@noaa.gov> wrote:
>
>>In my sample XML file...
>>
>><main>
>> <level1>
>> <level2>whatever</level2>
>> <level2>whatever</level2>
>> <level2>whatever</level2>
>> <level2>whatever</level2>
>> <level2>whatever</level2>
>> ...
>> </level1>
>></main>
>>
>>I have an variable number of level2 tags. Using XML::Simple, I can access
>>the
>>value of the 4th one by something like this:
>>
>> my $main = XMLin("myfile.xml");
>> print $main->{level1}->{level2}->[3]->{content};
>>
>>But I really want to know how many level2 records there are. I tried
>>variations
>>
> Hey isn't the "$main" name take already?
> New rule, you have to give more details than "I want to count all
> animals on Noah's ark". Noah didn't coun't them for a reason....
> Unless you positively know ahead of time the structure of the xml
> in question, you can't rely on xml::simple's output structure.
> I guess thats the other question.....
Answering the OP's question. If there are a variable number <level2>
my $element_count = @{ $main->{level1}->{level2} };
should do it (untested).
If there is only one level2 this will give an error unless you force
XML::Simple to make it an array.
------------------------------
Date: Wed, 30 Nov 2005 21:36:37 -0800
From: robic0
Subject: Re: XML::Simple array size
Message-Id: <ii2to1p7pmlg6ig14r1ohhl19eq3m4msga@4ax.com>
On Tue, 29 Nov 2005 14:01:02 +0100, "Dave" <daveandniki@ntlworld.com>
wrote:
>
><robic0> wrote in message news:g5uno11r6901vv00tnpln9r35j3q4v3jfc@4ax.com...
>> On Sat, 14 Feb 2004 17:58:08 -0500, Mark J Fenbers
>> <Mark.Fenbers@noaa.gov> wrote:
>>
>>>In my sample XML file...
>>>
>>><main>
>>> <level1>
>>> <level2>whatever</level2>
>>> <level2>whatever</level2>
>>> <level2>whatever</level2>
>>> <level2>whatever</level2>
>>> <level2>whatever</level2>
>>> ...
>>> </level1>
>>></main>
>>>
>>>I have an variable number of level2 tags. Using XML::Simple, I can access
>>>the
>>>value of the 4th one by something like this:
>>>
>>> my $main = XMLin("myfile.xml");
>>> print $main->{level1}->{level2}->[3]->{content};
>>>
>>>But I really want to know how many level2 records there are. I tried
>>>variations
>>>
>> Hey isn't the "$main" name take already?
>> New rule, you have to give more details than "I want to count all
>> animals on Noah's ark". Noah didn't coun't them for a reason....
>> Unless you positively know ahead of time the structure of the xml
>> in question, you can't rely on xml::simple's output structure.
>> I guess thats the other question.....
>
>Answering the OP's question. If there are a variable number <level2>
>my $element_count = @{ $main->{level1}->{level2} };
>should do it (untested).
>If there is only one level2 this will give an error unless you force
>XML::Simple to make it an array.
that should do it
$main=
{
$level1 =>
{
$level2 => [whatever,whatever,whatever,whatever],
},
};
>
------------------------------
Date: Wed, 30 Nov 2005 22:38:40 -0800
From: robic0
Subject: Re: XML::Simple array size
Message-Id: <od6to1tnnorv64hdfpen750dl66oa3ocsm@4ax.com>
On Wed, 30 Nov 2005 21:36:37 -0800, robic0 wrote:
>On Tue, 29 Nov 2005 14:01:02 +0100, "Dave" <daveandniki@ntlworld.com>
>wrote:
>
>>
>><robic0> wrote in message news:g5uno11r6901vv00tnpln9r35j3q4v3jfc@4ax.com...
>>> On Sat, 14 Feb 2004 17:58:08 -0500, Mark J Fenbers
>>> <Mark.Fenbers@noaa.gov> wrote:
>>>
>>>>In my sample XML file...
>>>>
>>>><main>
>>>> <level1>
>>>> <level2>whatever</level2>
>>>> <level2>whatever</level2>
>>>> <level2>whatever</level2>
>>>> <level2>whatever</level2>
>>>> <level2>whatever</level2>
>>>> ...
>>>> </level1>
>>>></main>
>>>>
>>>>I have an variable number of level2 tags. Using XML::Simple, I can access
>>>>the
>>>>value of the 4th one by something like this:
>>>>
>>>> my $main = XMLin("myfile.xml");
>>>> print $main->{level1}->{level2}->[3]->{content};
>>>>
>>>>But I really want to know how many level2 records there are. I tried
>>>>variations
>>>>
>>> Hey isn't the "$main" name take already?
>>> New rule, you have to give more details than "I want to count all
>>> animals on Noah's ark". Noah didn't coun't them for a reason....
>>> Unless you positively know ahead of time the structure of the xml
>>> in question, you can't rely on xml::simple's output structure.
>>> I guess thats the other question.....
>>
>>Answering the OP's question. If there are a variable number <level2>
>>my $element_count = @{ $main->{level1}->{level2} };
>>should do it (untested).
>>If there is only one level2 this will give an error unless you force
>>XML::Simple to make it an array.
$ref = eval { XMLin( $_xml , SuppressEmpty => '') };
# $ref = eval { XMLin( $_xml, ForceArray => 1, SuppressEmpty => '' )
been a while, thought force array had a problem depending on the
usage.
>
>that should do it
>
>$main=
>{
> $level1 =>
> {
> $level2 => [whatever,whatever,whatever,whatever],
> },
>};
>>
------------------------------
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 8720
***************************************