[29427] in Perl-Users-Digest
Perl-Users Digest, Issue: 671 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 22 16:09:53 2007
Date: Sun, 22 Jul 2007 13:09:07 -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 Sun, 22 Jul 2007 Volume: 11 Number: 671
Today's topics:
Re: @arts <zaxfuuq@invalid.net>
Re: @arts <tadmc@seesig.invalid>
Re: @arts <bik.mido@tiscalinet.it>
Re: @arts <zaxfuuq@invalid.net>
In deep complex XML <sow@sow.org.pl>
In deep complex XML <sow@sow.org.pl>
Re: In deep complex XML <eric-amick@comcast.net>
Re: Math <nospam-abuse@ilyaz.org>
Re: Math <nospam-abuse@ilyaz.org>
Re: Math <nospam-abuse@ilyaz.org>
Re: Math <wahab-mail@gmx.de>
Re: mysql DB specific primary key <tadmc@seesig.invalid>
Re: mysql DB specific primary key <paduille.4061.mumia.w+nospam@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 22 Jul 2007 13:08:54 -0700
From: "Wade Ward" <zaxfuuq@invalid.net>
Subject: Re: @arts
Message-Id: <CNSdnWsIpuaqEj7bnZ2dnUVZ_gydnZ2d@comcast.com>
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:GiFoi.2436$0v4.1803@trndny01...
> Wade Ward wrote:
>> The first symbol I don't understand is @arts. It looks like a special
>
> Oh come on! Are you saying you have never seen an array before? How long
> have you been programming Perl?
One month.
3 things led me to think that it was a special symbol.
1) It arose in the context of a module that post-dates my reference.
2) I didn't see anything that looked like a declaration to me. Apparently,
this is the declaration:
my ($since, @arts)=time-10*60*60;
RHS looks like a scalar. Before I modified the 24*60*60 to a smaller number
so as not to have 40k of output, it looked like time-24*60*60 would be a
biggish integer. I was thinking that this got assigned to $since, and that
@arts was something like zone in str2time(DATE [, ZONE]), that is, some type
of argument. In C and fortran, the declarations of arrays are
unmistakeable.
3) There exist special variables that begin with @ and look a lot like
@arts.
--
Wade Ward
------------------------------
Date: Sun, 22 Jul 2007 19:17:01 GMT
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: @arts
Message-Id: <slrnfa7b6f.siu.tadmc@tadmc30.sbcglobal.net>
Wade Ward <zaxfuuq@invalid.net> wrote:
> 3) There exist special variables that begin with @ and look a lot like
> @arts.
Please share your knowledge with me then.
Here are all of Perl's special variables that begin with @
that I can find:
@LAST_MATCH_END
@+
@LAST_MATCH_START
@-
@ARGV
@F
@INC
@_
Which one of those looks like @arts to you?
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Sun, 22 Jul 2007 21:26:41 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: @arts
Message-Id: <91b7a397f1pgb967hbcmpnhe8p186qp1gc@4ax.com>
On Sun, 22 Jul 2007 13:08:54 -0700, "Wade Ward" <zaxfuuq@invalid.net>
wrote:
>3 things led me to think that it was a special symbol.
>1) It arose in the context of a module that post-dates my reference.
If it were a variable exported by a module, then it wouldn't have been
a (Perl) special variable.
perldoc Exporter
perldoc perlvar
>2) I didn't see anything that looked like a declaration to me. Apparently,
>this is the declaration:
>my ($since, @arts)=time-10*60*60;
>RHS looks like a scalar. Before I modified the 24*60*60 to a smaller number
LHS is a list, thus RHS is a list, comprising one element, that gets
assigned to $since, @arts remains as empty as if it had been declared
like
my @arts;
>so as not to have 40k of output, it looked like time-24*60*60 would be a
>biggish integer. I was thinking that this got assigned to $since, and that
Given the well known return value of time(), which you must have
*surely* looked up in
perldoc -f time
it is obvious that the value you're dealing with is a "biggish
integer."
>@arts was something like zone in str2time(DATE [, ZONE]), that is, some type
Well, that's because str2time() takes arguments while my() is not
really a function, but a compiler directive, that wants a list of
variables, or undef values, period.
>of argument. In C and fortran, the declarations of arrays are
>unmistakeable.
In Perl, they can be, even though in all earnestness you're the first
one to make this mistake, that I know. And I'm even more surprised
that you didn't misinterpret in the same way another similar
assignment:
my (undef, $first, $last, undef)=$nntp->group($grp)
which came earlier in the code.
>3) There exist special variables that begin with @ and look a lot like
>@arts.
None that I know. The closest one that springs to mind being
<c>@ARGV</c>, but then the vast majority Perl special variables are
punctuation ones, while the few remaining one are all uppercase, with
the exception of $a and $b.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Sun, 22 Jul 2007 15:53:57 -0700
From: "Wade Ward" <zaxfuuq@invalid.net>
Subject: Re: @arts
Message-Id: <2J6dnRlDn_V7KD7bnZ2dnUVZ_v2unZ2d@comcast.com>
"Tad McClellan" <tadmc@seesig.invalid> wrote in message
news:slrnfa7b6f.siu.tadmc@tadmc30.sbcglobal.net...
> Wade Ward <zaxfuuq@invalid.net> wrote:
>
>> 3) There exist special variables that begin with @ and look a lot like
>> @arts.
>
>
> Please share your knowledge with me then.
Believe it or not, I didn't start this thread to look like an idiot,
although I seem to have achieved this.
> Here are all of Perl's special variables that begin with @
> that I can find:
>
> @LAST_MATCH_END
> @+
> @LAST_MATCH_START
> @-
> @ARGV
> @F
> @INC
> @_
>
>
> Which one of those looks like @arts to you?
@argv has 1)an initial @, 2)a subsequent 'ar' and 3) 5 letters total. If
you put it in the above list and asked reasonable people lacking perl
experience which one of these things is not like the other, I think any
guess would follow. Perl certainly has a motley assortment of funky-looking
variables, probably beginning with $_. A person can go cross-eyed looking
at all the things that begin with $.
--
Wade Ward
------------------------------
Date: Sun, 22 Jul 2007 08:14:42 -0700
From: sow <sow@sow.org.pl>
Subject: In deep complex XML
Message-Id: <1185117282.880963.93970@q75g2000hsh.googlegroups.com>
To professional geeks of perl.
I need to get values from complicated xml which is below:
$VAR1 = {
'report_params' => {
'customer_code' => 'name',
'customer_id' => '123',
'account_details' => [
{
'account_code' => 'account01',
'state_code' => 'DELETED',
'related_ani' => {
'state_code' =>
'DELETED',
'phone_number' =>
'123456',
'object_id' => '12',
'subscription' => [
{
'valid_to' => '2007-07-17T13:42:46',
'valid_from' => '2007-07-16T19:17:05',
'service_type_code' => 'VoIP',
'service_code' => 'serv01'
},
{
'valid_to' => '2007-07-18T12:15:16',
'session' => [
{
'currency_code' => 'QWE',
'duration' => '0',
'amount' => '0',
},
{
'currency_code' => 'QWE',
'duration' => '1313',
'amount' => '-1.75',
}
],
'valid_from' => '2007-07-17T13:43:23',
'service_type_code' => 'VoIP',
'service_code' => 'serv02'
},
{
'valid_to' => '2007-07-18T12:51:19',
'valid_from' => '2007-07-18T12:47:51',
'service_type_code' => 'VoIP',
'service_code' => 'serv03'
}
]
},
'created_date' => '2007-07-16T19:02:12'
},
{
'account_code' => 'account02',
'state_code' => 'ENABLED',
'related_ani' => {
'state_code' =>
'ENABLED',
'state_change_date' =>
'2007-07-18T12:56:33',
'phone_number' =>
'123456',
'object_id' => '13',
'subscription' => [
{
'session' => [
{
'currency_code' => 'QWE',
'duration' => '0',
'amount' => '0',
},
{
'currency_code' => 'QWE',
'duration' => '150',
'amount' => '-1.975',
},
{
'currency_code' => 'SEC',
'duration' => '101',
'amount' => '-101',
},
{
'currency_code' => 'SEC',
'duration' => '616',
'amount' => '-616',
}
],
'valid_from' => '2007-07-18T12:56:33',
'service_type_code' => 'VoIP',
'service_code' => 'serv04'
}
},
'created_date' => '2007-07-18T12:52:47'
}
],
};
and script in perl:
#!/usr/bin/perl
use XML::Simple;
$xml = new XML::Simple;
$data = $xml->XMLin($ARGV[0],
KeyAttr => {account_details => 'account_code',subscription =>
'service_code',session => 'currency_code'},
ForceArray => 1,
);
foreach $e (@{$data->{account_details}->{account02}->{related_ani}-
>{subscription}->{serv04}->{session}->{QWE}})
{
printf "value %20s\n",$e->{amount};
}
and I've error:
Pseudo-hashes are deprecated at ./script line 9.
No such pseudo-hash field "account02" at ./billing2 line 9.
Please write any advice. Thanks.
------------------------------
Date: Sun, 22 Jul 2007 08:41:51 -0700
From: sow <sow@sow.org.pl>
Subject: In deep complex XML
Message-Id: <1185118911.492653.209960@22g2000hsm.googlegroups.com>
I have problem with get specific values from xml script below:
$VAR1 = {
'report_params' => {
'customer_code' => 'name',
'customer_id' => '123',
'account_details' => [
{
'account_code' => 'account01',
'state_code' => 'DELETED',
'related_ani' => {
'state_code' => 'DELETED',
'phone_number' => '123456',
'object_id' => '12',
'subscription' => [
{
'valid_to' => '2007-07-17T13:42:46',
'valid_from' => '2007-07-16T19:17:05',
'service_type_code' => 'VoIP',
'service_code' => 'serv01'
},
{
'valid_to' => '2007-07-18T12:15:16',
'session' => [
{
'currency_code' => 'QWE',
'duration' => '0',
'amount' => '0',
},
{
'currency_code' => 'QWE',
'duration' => '1313',
'amount' => '-1.75',
}
],
'valid_from' => '2007-07-17T13:43:23',
'service_type_code' => 'VoIP',
'service_code' => 'serv02'
},
{
'valid_to' => '2007-07-18T12:51:19',
'valid_from' => '2007-07-18T12:47:51',
'service_type_code' => 'VoIP',
'service_code' => 'serv03'
}
]
},
'created_date' => '2007-07-16T19:02:12'
},
{
'account_code' => 'account02',
'state_code' => 'ENABLED',
'related_ani' => {
'state_code' => 'ENABLED',
'phone_number' => '123456',
'object_id' => '13',
'subscription' => [
{
'session' => [
{
'currency_code' => 'QWE',
'duration' => '0',
'amount' => '0',
},
{
'currency_code' => 'QWE',
'duration' => '150',
'amount' => '-1.975',
},
{
'currency_code' => 'SEC',
'duration' => '101',
'amount' => '-101',
},
{
'currency_code' => 'SEC',
'duration' => '616',
'amount' => '-616',
}
],
'valid_from' => '2007-07-18T12:56:33',
'service_type_code' => 'VoIP',
'service_code' => 'serv04'
}
},
'created_date' => '2007-07-18T12:52:47'
}
],
};
and script in perl:
#!/usr/bin/perl
use XML::Simple;
$xml = new XML::Simple;
$data = $xml->XMLin($ARGV[0],
KeyAttr => {account_details => 'account_code',subscription =>
'service_code',session => 'currency_code'},
ForceArray => 1,
);
foreach $e (@{$data->{account_details}->{account02}->
{related_ani}->{subscription}->{serv04}->{session}->{QWE}})
{
printf "value %20s\n",$e->{amount};
}
and I've error:
Pseudo-hashes are deprecated at ./script line 9.
No such pseudo-hash field "account02" at ./billing2 line 9.
Any advice?
------------------------------
Date: Sun, 22 Jul 2007 15:08:45 -0400
From: Eric Amick <eric-amick@comcast.net>
Subject: Re: In deep complex XML
Message-Id: <sja7a3tipt2t79t39vv78bdfdq8je90rm2@4ax.com>
On Sun, 22 Jul 2007 08:41:51 -0700, sow <sow@sow.org.pl> wrote:
>I have problem with get specific values from xml script below:
>
>$VAR1 = {
> 'report_params' => {
> 'customer_code' => 'name',
> 'customer_id' => '123',
> 'account_details' => [
> {
> 'account_code' => 'account01',
> 'state_code' => 'DELETED',
> 'related_ani' => {
> 'state_code' => 'DELETED',
> 'phone_number' => '123456',
> 'object_id' => '12',
> 'subscription' => [
> {
> 'valid_to' => '2007-07-17T13:42:46',
> 'valid_from' => '2007-07-16T19:17:05',
> 'service_type_code' => 'VoIP',
> 'service_code' => 'serv01'
> },
> {
> 'valid_to' => '2007-07-18T12:15:16',
> 'session' => [
> {
> 'currency_code' => 'QWE',
> 'duration' => '0',
> 'amount' => '0',
> },
> {
> 'currency_code' => 'QWE',
> 'duration' => '1313',
> 'amount' => '-1.75',
> }
> ],
> 'valid_from' => '2007-07-17T13:43:23',
> 'service_type_code' => 'VoIP',
> 'service_code' => 'serv02'
> },
> {
> 'valid_to' => '2007-07-18T12:51:19',
> 'valid_from' => '2007-07-18T12:47:51',
> 'service_type_code' => 'VoIP',
> 'service_code' => 'serv03'
> }
> ]
> },
> 'created_date' => '2007-07-16T19:02:12'
> },
> {
> 'account_code' => 'account02',
> 'state_code' => 'ENABLED',
> 'related_ani' => {
> 'state_code' => 'ENABLED',
> 'phone_number' => '123456',
> 'object_id' => '13',
> 'subscription' => [
> {
> 'session' => [
> {
> 'currency_code' => 'QWE',
> 'duration' => '0',
> 'amount' => '0',
> },
> {
> 'currency_code' => 'QWE',
> 'duration' => '150',
> 'amount' => '-1.975',
> },
> {
> 'currency_code' => 'SEC',
> 'duration' => '101',
> 'amount' => '-101',
> },
> {
> 'currency_code' => 'SEC',
> 'duration' => '616',
> 'amount' => '-616',
> }
> ],
> 'valid_from' => '2007-07-18T12:56:33',
> 'service_type_code' => 'VoIP',
> 'service_code' => 'serv04'
> }
> },
> 'created_date' => '2007-07-18T12:52:47'
> }
> ],
> };
>
>and script in perl:
>
>#!/usr/bin/perl
>use XML::Simple;
>$xml = new XML::Simple;
>$data = $xml->XMLin($ARGV[0],
>KeyAttr => {account_details => 'account_code',subscription =>
> 'service_code',session => 'currency_code'},
>ForceArray => 1,
>);
>
>foreach $e (@{$data->{account_details}->{account02}->
> {related_ani}->{subscription}->{serv04}->{session}->{QWE}})
>{
>printf "value %20s\n",$e->{amount};
>}
>
>and I've error:
>Pseudo-hashes are deprecated at ./script line 9.
>No such pseudo-hash field "account02" at ./billing2 line 9.
>
>Any advice?
Dump the structure of $data after you construct it; I think you'll find
account02 is not a hash reference.
--
Eric Amick
Columbia, MD
------------------------------
Date: Sun, 22 Jul 2007 18:31:03 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Math
Message-Id: <f807p7$2p1p$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Robert Hicks
<sigzero@gmail.com>], who wrote in article <1184809614.126019.220110@x40g2000prg.googlegroups.com>:
> I realize that any math in Perl is probably slower than the same math
> in "C" but I was wondering if Perl was as accurate as "C" in math
> computations. I don't see why it wouldn't be but I thought I would ask
> as a heavy spherical math project is on the horizon.
For some unfathomable reasons, Perl uses non-invertible transformations
between strings and numbers. So if your handling of numbers involves
converting them to strings, then back, the precision will be lost.
perldoc perlnumber
for details.
Hope this helps,
Ilya
------------------------------
Date: Sun, 22 Jul 2007 18:34:28 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Math
Message-Id: <f807vk$2p2a$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Mirco Wahab
<wahab@chemie.uni-halle.de>], who wrote in article <f7n0q3$26ae$1@nserver.hrz.tu-freiberg.de>:
> From my own experiences: Perl is not *that* slow in
> numerical thinks.
The slowdown due to *literal* translation of a C program to a Perl
program is, in my experience, between 80x and 200x. Whether it is
tolerable depends in the usage pattern.
Hope this helps,
Ilya
------------------------------
Date: Sun, 22 Jul 2007 18:40:20 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Math
Message-Id: <f808ak$2p6f$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Sisyphus
<sisyphus1@nomail.afraid.org>], who wrote in article <46a03093$0$25982$afc38c87@news.optusnet.com.au>:
> According to my Math::BigFloat (version 1.51) documentation you can, for
> example:
>
> use Math::BigFloat lib => 'GMP';
I do not know how it happens now, but some time ago the architecture
of Math::BigInt and Math::BigFloat modules was absolutely broken
performance-wise: AFAIK, instead of *delegating* the work to the
optimized modules, it creates *wrappers* about the optimized stuff.
Since the wrappers are written in Perl, the performance should suffer
a lot - unless you do calculations with madly big numbers (as in
crypto), so each "elementary operation" takes long enough to make
overhead of Perl wrappers is not crucial.
> and that will, as I understand it, use the GMP integer routines instead of
> the (pure perl) M::BI integer routines - so long as Math::BigInt::GMP has
> been installed.
Hope this helps,
Ilya
------------------------------
Date: Sun, 22 Jul 2007 20:53:13 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Math
Message-Id: <f809e3$rkh$1@mlucom4.urz.uni-halle.de>
Ilya Zakharevich wrote:
> [A complimentary Cc of this posting was sent to
> Mirco Wahab
> <wahab@chemie.uni-halle.de>], who wrote in article <f7n0q3$26ae$1@nserver.hrz.tu-freiberg.de>:
>> From my own experiences: Perl is not *that* slow in
>> numerical thinks.
>
> The slowdown due to *literal* translation of a C program to a Perl
> program is, in my experience, between 80x and 200x. Whether it is
> tolerable depends in the usage pattern.
OK, if the program does depend *only* on
number crunching, the ratio I'd expect
would be around 1:100, as can also can
be seen from the numerical benchmarks
on http://shootout.alioth.debian.org,
eg. http://shootout.alioth.debian.org/debian/benchmark.php?test=nbody&lang=all
(planetary body movement simulation)
or http://shootout.alioth.debian.org/debian/benchmark.php?test=mandelbrot&lang=all
(mandelbrot set generation)
Thanks & regards
M.
------------------------------
Date: Sun, 22 Jul 2007 11:31:37 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: mysql DB specific primary key
Message-Id: <slrnfa71j9.qg7.tadmc@tadmc30.sbcglobal.net>
pistachio <hpbenton@gmail.com> wrote:
> The
> database has gaps in the primary key sequence from deleting data, I
> want to put data into those gaps.
Why do you want to put data into those gaps?
That is, what do you think that that will buy you?
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Sun, 22 Jul 2007 18:15:37 GMT
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: mysql DB specific primary key
Message-Id: <d9Noi.9619$rR.4656@newsread2.news.pas.earthlink.net>
On 07/22/2007 01:29 AM, pistachio wrote:
> Hello everyone,
>
> Hopefully a quick one. I have a database in which I want to put some
> data into from a file. I've parsed through the file got what I want
> and am about to put it into the database. But I want to check the
> primary key and see if it's free before I put the data in. The
> database has gaps in the primary key sequence from deleting data, I
> want to put data into those gaps. Is there a quick way to do this. I
> was going to do some like :
>
> 1) Go through database see where no data for primary key
> 2) sort this number into an array
> 3) use array to specify empty database slots.
>
> Any ideas would be great esp with some code. Or how to do the 1st line
> (not /usr/bin/perl -w for the funny ppl out there :p).
>
> Thanks
>
> Paul
>
I don't think there is a quick way. I would suggest that you create a
table to hold open keys and write an SQL script to populate that table.
When your Perl script needs an open key, it would grab a key from the
"open_keys" table (sorted) and delete the record from that table.
Eventually, the Perl script would break because you would have run out
of open keys, but your primary objective (to fill the open slots) will
have been fulfilled.
------------------------------
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 V11 Issue 671
**************************************