[23383] in Perl-Users-Digest
Perl-Users Digest, Issue: 5602 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 2 09:05:52 2003
Date: Thu, 2 Oct 2003 06:05:10 -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, 2 Oct 2003 Volume: 10 Number: 5602
Today's topics:
[newbie] how to walk values on a column in perl (John)
Re: [newbie] how to walk values on a column in perl <ak+usenet@freeshell.org>
Backup your projects neatly <Dont.Reply@please.com>
Re: Bad protocol 'tcp' error - ActiveState Perl <mike_lottridge@nospam.hotmail.com>
Re: code not working..ideas please? <geoff.cox@blueyonder.co.uk>
Re: code not working..ideas please? <geoff.cox@blueyonder.co.uk>
Re: dashes or tildies? <HelgiBriem_1@hotmail.com>
Data::Compare bug - Fabien Tassin please contact me <usenet@barnyard.co.uk>
Re: Data::Compare bug - Fabien Tassin please contact me <sv99oya02@sneakemail.com>
DBI <someone@somewhere.com>
Re: DBI <kuujinbo@hotmail.com>
Re: Debug Messages (Anno Siegel)
Re: Downloading older versions of Perl <dha@panix.com>
Re: How to generate this list? <krahnj@acm.org>
Re: Numbers not acting like numbers (Heinrich Mislik)
Packing a notebook <this.is@fake.address>
Re: Packing a notebook <this.is@fake.address>
question about hash ordering (John)
Re: question about hash ordering (Sam Holden)
Re: Software Marketing News <S._member@newsguy.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 2 Oct 2003 05:21:35 -0700
From: news2003@wanadoo.es (John)
Subject: [newbie] how to walk values on a column in perl
Message-Id: <3bd6db81.0310020421.5690eaad@posting.google.com>
Hi gurus,
If I want to walk the colunms on one array of array, How do you do
that?
This is my case
@a = (
[qw/a b c d e/],
[qw/1 b m e f/],
[qw/c b n g h/],
[qw/j b l z y/]
),
and I want to check all values on a row to see if are the same. (on
this case all for column 1).
How I could do that? I always can transpose the array and operate over
all the elements in the row, but I think that must be a way to work
over the columns, without change the original array.
Any idea.
Thanks a million for your help
J
------------------------------
Date: Thu, 2 Oct 2003 12:30:13 +0000 (UTC)
From: Andreas Kahari <ak+usenet@freeshell.org>
Subject: Re: [newbie] how to walk values on a column in perl
Message-Id: <slrnbno6ik.cp9.ak+usenet@otaku.freeshell.org>
In article <3bd6db81.0310020421.5690eaad@posting.google.com>, John wrote:
[cut]
> and I want to check all values on a row to see if are the same. (on
> this case all for column 1).
my $val;
foreach my $row (@a) {
if (!defined $val) {
$val = $row->[1];
next;
}
if ($row->[1] ne $val) {
die "Column is not uniform\n";
}
}
--
Andreas Kähäri
------------------------------
Date: Thu, 2 Oct 2003 13:48:45 +0200
From: "Guy" <Dont.Reply@please.com>
Subject: Backup your projects neatly
Message-Id: <blgvp4$217$1@news2.netvision.net.il>
If you are tired of trying to timely backup your project you should read
this message.
Relative Reversion is a new innovative product that will not only schedule
your backup sessions incrementally, but it will also manage the number of
backup snapshots that you want to keep on your storage media. Older backup
snapshots are cleared automatically per your specifications, which makes
room for newer backup snapshots to be stored. All the backup snapshots are
taken incrementally, which reduces the storage requirements to the bear
minimum. That means that after a simple configuration of Relative Reversion
you can concentrate on your job while the data that you produce is taken
care of by Relative Reversion.
Relative reversion supports a novel E-GFSTM and STDTM algorithms, which
enables you to define the number of backup snapshots to save based on the
time they were taken, and to automatically clear outdated files. Several
definitions exist for Intra-daily, Daily, Weekly, Monthly, and Special
backup snapshots.
Take this opportunity to be among the first to enjoy this robust product,
and bring a peace to your mind. Visit our web site at www.datamills.com and
download a time limited edition (expires on December 21, 2003) of this
product. You may also simply register at our site, as an early adopter of
this product, and automatically earn a 50% discount coupon for the purchase
of this product see our web site for details.
Please do not reply to this message, replies to this message are not
monitored.
Guy P.
DataMills - Better Data Care Solutions
www.datamills.com
------------------------------
Date: Thu, 02 Oct 2003 05:48:11 GMT
From: "Mike Lottridge" <mike_lottridge@nospam.hotmail.com>
Subject: Re: Bad protocol 'tcp' error - ActiveState Perl
Message-Id: <v_Oeb.30278$Wd7.28095@nwrddc03.gnilink.net>
Thanks! I've searched them, to no avail... maybe that says more about me
than the content of the lists....
"ko" <kuujinbo@hotmail.com> wrote in message
news:92d64088.0310011435.13de3f48@posting.google.com...
> "Mike Lottridge" <res6mtpc@verizon.net> wrote in message
news:<qZCeb.540$3b7.189@nwrddc02.gnilink.net>...
> > I'm getting an bad protocol error 'tcp' whenever I use any of the LWP
> > modules (and PPM as well). I'm using a Windows 2000 system. There's not
a
> > problem with tcp on port 80, i can browse the net, plus run other
command
> > line cygwin utilities (wget, ...) without problems.
>
> Have you tried the ActiveState mailing lists? There's one specifically for
ppm:
>
> http://aspn.activestate.com/ASPN/Mail/Browse/Threaded/ppm
>
> HTH - keith
------------------------------
Date: Thu, 02 Oct 2003 09:21:21 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: Re: code not working..ideas please?
Message-Id: <tfrnnv0jult1squqqum9rnhvhqdvh32dh5@4ax.com>
On Wed, 1 Oct 2003 08:47:28 -0500, tadmc@augustmail.com (Tad
McClellan) wrote:
>Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
>> On Tue, 30 Sep 2003 16:04:07 -0500, tadmc@augustmail.com (Tad
>> McClellan) wrote:
>>>Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
>>>
>>>> $word =~ tr/A-Z/a-z/;
>
>
>>>Your method does not respect locales:
>
>
>> Thanks for your reply but "respect locales" ?
>
>
>"locale"s are for dealing with languages other than English (sorta).
OK thanks
Geoff
>
>
> perldoc perllocale
------------------------------
Date: Thu, 02 Oct 2003 09:21:47 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: Re: code not working..ideas please?
Message-Id: <fgrnnv0691ob4vmmdgvggabs35r8fhsqdn@4ax.com>
On Wed, 01 Oct 2003 11:59:57 +0000, Helgi Briem
<HelgiBriem_1@hotmail.com> wrote:
>On Wed, 01 Oct 2003 08:39:46 GMT, Geoff Cox
><geoff.cox@blueyonder.co.uk> wrote:
>
>>On Tue, 30 Sep 2003 16:04:07 -0500, tadmc@augustmail.com (Tad
>>McClellan) wrote:
>>
>>>Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
>>>
>>>> $word =~ tr/A-Z/a-z/;
>
>>>You should use the function for lowercasing when you want to
>>>lowercase. Your method does not respect locales:
>>
>>> $word = lc($word);
>
>>Thanks for your reply but "respect locales" ?
>
>Would your way recognise that 'Þ' (ord=222) is a valid letter in
> Icelandic and has the lowercase version 'þ' (ord=254)?
>That's locale. Here's an example:
>
>use locale qw(Icelandic);
>print lc('ÞÓR');
>
>Output:
Thanks for the explanation.
Cheers
Geoff
>þór
------------------------------
Date: Thu, 02 Oct 2003 10:53:40 +0000
From: Helgi Briem <HelgiBriem_1@hotmail.com>
Subject: Re: dashes or tildies?
Message-Id: <hj0onvsvjlbjhi4ttghmerdsuid4sjhlbn@4ax.com>
On Wed, 01 Oct 2003 22:25:52 +0200, Tore Aursand <tore@aursand.no>
wrote:
>In addition, I would have used an existing module to actually send the
>mail. Never done that in a long time myself, but I remember Net::SMTP
>being a nice one.
I like MIME::Lite.
------------------------------
Date: Thu, 02 Oct 2003 13:00:49 +0100
From: David Cantrell <usenet@barnyard.co.uk>
Subject: Data::Compare bug - Fabien Tassin please contact me
Message-Id: <ojlmnvc889pet2j0aac19b5grf7lm5uld0@4ax.com>
I have found one fairly serious bug in Data::Compare, and one thing
that I think is a bug but I'm not sure of.
The possible bug is that Fabien uses /o on a pattern match with an
interpolated scalar, where the scalar's value will change from one
invocation to another and I don't think he wants to just use the first
value for all eternity.
The serious bug is that it Does The Wrong Thing when asked to compare
objects which overload the stringify and numify operations. I have
patched it to deal with Scalar::Properties objects in what I think is
the right way.
I've tried contacting Fabien about this, but he isn't answering his
mail. Perhaps the address in the docs is out of date. If anyone
knows how to contact him, please can you pass this on?
If I don't hear anything in a few weeks, I'll upload my patched
version to CPAN, if anyone else wants it before then, please mail me.
--
David Cantrell | http://www.cantrell.org.uk/david
------------------------------
Date: Thu, 02 Oct 2003 14:55:14 +0200
From: =?ISO-8859-1?Q?Steffen_M=FCller?= <sv99oya02@sneakemail.com>
Subject: Re: Data::Compare bug - Fabien Tassin please contact me
Message-Id: <blh772$ev5$1@news.rz.uni-karlsruhe.de>
David Cantrell wrote:
[...]
> If I don't hear anything in a few weeks, I'll upload my patched
> version to CPAN, if anyone else wants it before then, please mail me.
If you can't reach the author and want peer review nonetheless, try
subscribing to the code-review-ladder /at/ lists.netthink.co.uk mailing
list. It'd be expected that you offer the same service - in a reasonable
dose - to other list dwellers, though.
Steffen
--
@n=([283488072,6076],[2105905181,8583184],[1823729722,9282996],[281232,
1312416],[1823790605,791604],[2104676663,884944]);$b=6;@c=' -/\_|'=~/./g
;for(@n){for$n(@$_){map{$h=int$n/$b**$_;$n-=$b**$_*$h;$c[@c]=$h}reverse
0..11;push@p,map{$c[$_]}@c[reverse$b..$#c];$#c=$b-1}$p[@p]="\n"}print@p;
------------------------------
Date: Thu, 2 Oct 2003 12:17:23 +0100
From: "Bigus" <someone@somewhere.com>
Subject: DBI
Message-Id: <blh1g4$14t0@newton.cc.rl.ac.uk>
Hi
I have a mySQL database with a table called "tickets" in it. There are 3
columns in the table: email | time | ticket.
I have 3 variables $email, $time and $ticket containing an email address,
Perl time and session ticket, respectively.
What I want to do is check if a row already exists in the database for the
email address contained in $email. If it does then perform an UPDATE, if it
doesn't INSERT a new row.
This is the basic code I have for this task:
======================
# check if row exists and update / insert as appropriate
@row = $db->selectrow_array("SELECT * FROM tickets WHERE email = '$email'");
if($row[0] =~ /\w+/){
$db->do("UPDATE tickets SET time = '$thetime', ticket = '$ticket'
WHERE email = '$email'");
}
else{
$db->do("INSERT INTO tickets (email,time,ticket) VALUES
('$email','$thetime','$ticket')");
}
# check for DB errors
if($db->errstr){
print $db->errstr;
}
========================
That works to a point, but it's not bullet-proof. ie: some email addresses
have, for example, a single quote in them like:
f.o'neill@somewhere.com
A quote causes the above to generate the following error:
You have an error in your SQL syntax near
'neill@somewhere.com','1065092739','618BA732FF2A739F6E')' at line 1.
Having looked at the DBI CPAN page I explored qq{..} and q{..}but can't see
to get them to work. That is, in the case of the INSERT row:
1) $db->do(qq{INSERT INTO tickets (email,time,ticket) VALUES
('$email','$thetime','$ticket')});
or
$db->do(qq{INSERT INTO tickets (email,time,ticket) VALUES
($email,$thetime,$ticket)});
comes up with the same ERROR as above.
q{..} doesn't apparently handle interpolated variables, so any ideas how I
can make this bullet proof, regardless of what characters $email might
contain in it?
Thanks
Bigus
------------------------------
Date: Thu, 02 Oct 2003 20:46:20 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: DBI
Message-Id: <blh39r$mp0$1@pin3.tky.plala.or.jp>
Bigus wrote:
[snip]
> That works to a point, but it's not bullet-proof. ie: some email addresses
> have, for example, a single quote in them like:
>
> f.o'neill@somewhere.com
>
> A quote causes the above to generate the following error:
>
> You have an error in your SQL syntax near
> 'neill@somewhere.com','1065092739','618BA732FF2A739F6E')' at line 1.
Look into the placeholders and bind values section of the DBI docs.
HTH - keith
------------------------------
Date: 2 Oct 2003 07:12:39 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Debug Messages
Message-Id: <blgj57$4qi$1@mamenchi.zrz.TU-Berlin.DE>
Eric Schwartz <emschwar@pobox.com> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> > Also like in C, it can't be (easily) activated from the command line. If
> > you want that, it is probably better to provide a key like --debug via
> > Getopt::Long and query the option.
>
> That isn't easy? Wow, you must have a lot lower standard for "hard"
> than I do. -_^;
>
> use Getopt::Long;
> my %opt = (); # initialization not necessary, just a habit
> die 'Error parsing options' unless GetOptions(\%opt, "debug");
No, that *is* the easy solution. Setting a compile-time constant
from the command line (so that debugging statements are not even
compiled) requires a bit of BEGIN trickery.
Anno
------------------------------
Date: Thu, 2 Oct 2003 04:16:38 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: Downloading older versions of Perl
Message-Id: <slrnbnn9l6.go.dha@panix2.panix.com>
In article <3f7a6d21.106101070@news.erols.com>, Jay Tilton wrote:
> lphiecfu2002@yahoo.com (cfu20) wrote:
>
>: Does anyone know where I can download older versions of Perl binary
>: distributions (specifically 4.0) ?
>
> http://cpan.org/src/unsupported/
If you're downloading this for any reason beyond academic interest, of
course, you should definitely take into consideration that there's a
*reason* for that directory's name... :-)
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
And you know, you can have all the good audio gear in the world, but
unless you make a point of asking the informant to not eat a Snickers
while he's talking, it's all for naught. - TorgoX, #perl
------------------------------
Date: Thu, 02 Oct 2003 11:01:21 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: How to generate this list?
Message-Id: <3F7C054A.45919004@acm.org>
Mike Flannigan wrote:
>
> "John W. Krahn" wrote:
> >
> > I don't know if this is the best way but:
> >
> > my @array = qw/ A A A A B B C D D D /;
> >
> > print "$_\n" for glob "{@{[ join ',', @array ]}}" x @array;
>
> I don't know why, but on my Win2000 box this gives
> the error:
> Unmatched right square bracket at . . . line 6, at end of line.
>
> I sure don't see that:
>
> use strict;
> use warnings;
>
> y @array = qw/ A A A A B B C D D D /;
>
> print "$_\n" for glob "{@{[ join ',', @array ]}}" x @array;
You didn't copy it correctly. What you have is the translation operator
y@@@ followed by 'array ]}}" x @array;'. Change "y @array" to "my
@array".
John
--
use Perl;
program
fulfillment
------------------------------
Date: 02 Oct 2003 09:18:21 GMT
From: Heinrich.Mislik@univie.ac.at (Heinrich Mislik)
Subject: Re: Numbers not acting like numbers
Message-Id: <3f7bed56$0$24542$3b214f66@usenet.univie.ac.at>
In article <BB9F9EA1.17A8%dasquith@austin.rr.com>, dasquith@austin.rr.com says...
>I have subroutine for computing base-10 log. With a recent upgrade from
>Perl5.6 to Perl5.8 on both Linux and Solaris systems, a very large program
>with a proven track record is not behaving right. The subroutine snippet is
>as follows.
>
>use constant logof10 => scalar log(10);
>use constant ZERO => scalar 0;
>sub log10 {
> my $n = shift;
> #my $n = &repackit(shift); # HACK HERE
> ($n <= ZERO) ? undef : log($n)/logof10;
>}
>
Could there be some non-printable characters in your data? Consider the
following one-liner:
#perl -e '$_ = "\x080.1";print "$_\n";print "equal\n" if $_ <= 0'
0.1
equal
I couldn't find an example, where the pack/unpack removes such a character,
but this may even be specific to your platform.
hth
--
Heinrich Mislik
Zentraler Informatikdienst der Universitaet Wien
A-1010 Wien, Universitaetsstrasse 7
Tel.: (+43 1) 4277-14056, Fax: (+43 1) 4277-9140
------------------------------
Date: Thu, 2 Oct 2003 12:54:56 +0100
From: "Richard S Beckett" <this.is@fake.address>
Subject: Packing a notebook
Message-Id: <blh3p3$nff$1@newshost.mot.com>
Guys,
I'm getting some 'interesting' results when my window containing a notebook
is displayed.
Is there a correct order for packing?
i.e. I have a notebook, pages, and panes. I define the notebook first, then
the pages, then the panes, but how/what order should I pack them in?
Thanks.
--
R.
GPLRank +79.699
------------------------------
Date: Thu, 2 Oct 2003 13:06:05 +0100
From: "Richard S Beckett" <this.is@fake.address>
Subject: Re: Packing a notebook
Message-Id: <blh4e1$obr$1@newshost.mot.com>
Oops! Sorry, wrong NG.
--
R.
GPLRank +79.699
"Richard S Beckett" <this.is@fake.address> wrote in message
news:blh3p3$nff$1@newshost.mot.com...
> Guys,
>
> I'm getting some 'interesting' results when my window containing a
notebook
> is displayed.
>
> Is there a correct order for packing?
>
> i.e. I have a notebook, pages, and panes. I define the notebook first,
then
> the pages, then the panes, but how/what order should I pack them in?
>
> Thanks.
> --
> R.
> GPLRank +79.699
>
>
------------------------------
Date: 2 Oct 2003 01:38:24 -0700
From: news2003@wanadoo.es (John)
Subject: question about hash ordering
Message-Id: <3bd6db81.0310020038.7dea4243@posting.google.com>
HI,
I have this.
@arr = qw(ab a b ab ba ba ab ba);
and I would like to classify the index with the values:
@output = ([0, 3, 6],
[1],
[2],
[4, 5, 7]
);
or in hash
%output = (
0 => [0, 3, 6],
1 => [1],
2 => [2],
4 => [4, 5, 7]
);
on this situation I don't know which approach is the best the array
one or the hash, in order to classify then and also in performance.
What will be you approach?
Thanks for your help
J
------------------------------
Date: 2 Oct 2003 08:54:41 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: question about hash ordering
Message-Id: <slrnbnnpuh.nst.sholden@flexal.cs.usyd.edu.au>
On 2 Oct 2003 01:38:24 -0700, John <news2003@wanadoo.es> wrote:
> HI,
>
> I have this.
>
>
> @arr = qw(ab a b ab ba ba ab ba);
>
> and I would like to classify the index with the values:
>
> @output = ([0, 3, 6],
> [1],
> [2],
> [4, 5, 7]
> );
> or in hash
>
> %output = (
> 0 => [0, 3, 6],
> 1 => [1],
> 2 => [2],
> 4 => [4, 5, 7]
> );
>
>
> on this situation I don't know which approach is the best the array
> one or the hash, in order to classify then and also in performance.
It depends on what you want to do with it, and how big the data
will be, and numerous other factors.
For example, if you want to know what the nth unique element is
(where, for example, the 4th unique element in that example is 'ba'),
then the array will allow you to do so in constant time:
$arr[$output[$i][0]]
While the hash will require O(NlogN) time (you'd have to sort the keys).
Then again, if you know the index of the first occurance of an item you
wish to find the list of occurances for (or want to know if that index
is the first occurance of the item), then the hash approach will
allow you to do so in constant time, while the array approach will
require O(logN).
So performance depends on the operations you need (as always).
--
Sam Holden
------------------------------
Date: 2 Oct 2003 03:49:22 -0700
From: S. Housley <S._member@newsguy.com>
Subject: Re: Software Marketing News
Message-Id: <blgvri02h1r@drn.newsguy.com>
>> I'm not quite sure if this is an appropriate place to post this,
>
>
>Does your newsletter have an article regarding Perl in it?
The newsletter is for developers and addresses issues that software developers
deal with and provides resources and tips for developers, its not specific to
perl but software development. I apologize if it was inappropriate but I
thought there might be interest.
Sharon Housley
Software Marketing Resource
http://www.softwaremarketingresource.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.
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 5602
***************************************