[19445] in Perl-Users-Digest
Perl-Users Digest, Issue: 1640 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 28 14:10:41 2001
Date: Tue, 28 Aug 2001 11:10:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <999022212-v10-i1640@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 28 Aug 2001 Volume: 10 Number: 1640
Today's topics:
MySQL grants question... (Gil G.)
Re: Perl number conversion Utilities <tinamue@zedat.fu-berlin.de>
Re: Perl number conversion Utilities (Anno Siegel)
Re: Preliminary task description <iltzu@sci.invalid>
Problems using Algorithm::Diff <jcook@strobedata.com>
Re: Problems using Algorithm::Diff <tony_curtis32@yahoo.com>
Re: Problems using Algorithm::Diff <jcook@strobedata.com>
Re: Profiling r1ckey@yahoo.com
Quota module experts: I need your help <radiotito@yahoo.com>
Re: REGEX <godzilla@stomp.stomp.tokyo>
Re: REGEX <godzilla@stomp.stomp.tokyo>
Re: RegEx? (David Wall)
Whence pmtools? (Chris Fedde)
Re: Will Perl report on variables no longer used?? <iltzu@sci.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 28 Aug 2001 17:39:36 GMT
From: gil@nospam-keskydee.com (Gil G.)
Subject: MySQL grants question...
Message-Id: <3b8bd738.1032705@news.verizon.net>
Hello,
Sorry, this is a bit off subject, I could not find a MySQL newsgroup
in my groups file... The MySQL manual and book by Dubois did not
provide me with an answer.
I need some help to solve the following problem:
As root, I can create a database and access it, no problem.
However, when I try to grant permissions to a user on a database
created by root, it seems to work (no error messages), using the
command line or phpmyadmin, but access is still denied...??
I did restart MySQL after adding privileges, no change.
Did I forget something?
Thanks a lot, sincerely,
Gil.
PS: What is the best group for such MySQL questions?
------------------------------
Date: 28 Aug 2001 15:47:20 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: Perl number conversion Utilities
Message-Id: <9mgee8$23d6c$2@fu-berlin.de>
Joseph Hasting <hasting@agere.com> wrote:
> Look. I hate being like you people and submitting pointless entries to
> this newsgroup, but you people need to realize that these subroutines
> will translate a decimal number into a hexidecimal number, period. Put
> them in a script, if you have a hexidecimal variable, the subroutine
> will return the hexideciaml version, THAT IS THE POINT OF THE
> SUBROUTINES!!! I don't care what you want to call the subroutines.
hm. well. write a module that contains these routines, if
you think they are useful. but expect to get many complaints
by people who think these routines are really dealing with
decimals. they don't.
just try
print bin2dec dec2bin -1
-1 is a decimal. why am I getting 4294967295 as a result
when I would expect -1?
> I originally made this post to help people
if you really want to help, then you should accept critique and
constructive suggestions.
> (who actually do PERL work
> rather than make pointless semantic complaint posts to this newsgroups)
> by having all of the conversion subroutines together, not to have some
> people complain about the name of the routines. If you people want to
> sound smart by flooding the newsgroup with semantics complaints, GOTO
> ANOTHER NEWSGROUP.
guess you'll get many plonks for saying that.
--
http://www.tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
--- Warning: content of homepage hopelessly out-dated ---
------------------------------
Date: 28 Aug 2001 16:04:24 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl number conversion Utilities
Message-Id: <9mgfe8$aic$1@mamenchi.zrz.TU-Berlin.DE>
According to Joseph Hasting <hasting@agere.com>:
[Joseph top-posted in reply to Randal. Jeopardectomy performed.]
> Look. I hate being like you people and submitting pointless entries to
> this newsgroup, but you people need to realize that these subroutines
> will translate a decimal number into a hexidecimal number, period. Put
The only problem is there are no decimal or hexadecimal numbers,
just numbers and various representations of numbers. Nor are there
hexidecimal numbers, but that's a different point.
Unawareness of the distinction between a number and its representation
is a source of frequent misunderstandings. Yours was nicely corrected
by one of the worlds most prominent Perl experts.
> them in a script, if you have a hexidecimal variable, the subroutine
> will return the hexideciaml version, THAT IS THE POINT OF THE
> SUBROUTINES!!! I don't care what you want to call the subroutines.
So what's all this shouting about?
> I originally made this post to help people (who actually do PERL work
> rather than make pointless semantic complaint posts to this newsgroups)
Randal has done more Perl (not PERL[1]) work than most people. You have
no idea.
> by having all of the conversion subroutines together, not to have some
> people complain about the name of the routines. If you people want to
> sound smart by flooding the newsgroup with semantics complaints, GOTO
> ANOTHER NEWSGROUP.
Hehe.
You posted a bunch of amateurishly written conversion routines, and
explained them in terms of a fundamental misconceptions. Expect to
be criticized.
Anno
[1] Yes, I know you don't care.
--
use overload '${}' => sub { \ 'Just '}, '@{}' => sub { [ 'another ']},
'%{}' => sub { { a => 'Perl '}}, '&{}' => sub { sub { print @_, 'hacker'}};
$plop = bless [];
$plop->( $$plop, $plop->[ 0], $plop->{ a});
------------------------------
Date: 28 Aug 2001 17:45:51 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Preliminary task description
Message-Id: <999019284.29801@itz.pp.sci.fi>
In article <9me2r0$lmc$05$1@news.t-online.com>, Steffen Müller wrote:
>This isn't yet complete and not completely up to date, but I'm posting it so
>you guys can comment it before I finish.
[snip]
>- The playing ground is a 2-dimensional plane (a list of
> lists) that has a fixed size, but whenever an entity
> steps over its boundaries, it is 'teleported' to the
> other edge of the 'world' without it knowing that.
> It can still see over the edge of the world to the
> other side.
The technical name for such a topology is a "flat torus". You might
want to mention that for those who recognize the term.
> The entities cannot distinguish between different enemy
> strategies.
Why's that? Assigning a random ID to each strategy, and letting the
entities see the ID of the others, would lead to more interesting
strategies, since it allows recognition and learning.
> -> Problem: What if multiple instances (entities) of the same
> strategy meet?
> -> If only two entities of the same entry meet with no
> opponents, they do not fight each other. Nothing happens.
Well, that hardly matters. In any case, two-way meetings are
uninteresting under your rules, since always defecting will lead to
either victory or a tie (if the other always defects too).
(Unless the entities could recognize the strategies of others, in which
case behavior in two-way encounters could affect behavior in later
multi-way encounters.)
> -> If a number of entities of the same strategy and any
> opponents meet: (I'm very unsure about this section!)
> -> The tournament could be carried out as normal with
> the entities of the same strategy knowing when they
> confont each other. They could try to adjust their
> encounter-strategy if they meet a mate.
I think this would be the more interesting option. Yes, it would lead
to mobbing -- but excessive mobbing would backfire, since it ties up
entities that could be winning battles elsewhere. So the strategies
would have to try to find a balance.
>- Inter-entity communication?
[snip]
> This option would really make the contest a competition... and
> programming the platform a pain!
Why? Just let the entities pass arbitrary scalars to each other in turn
until they're satisfied, and let the players come up with communication
protocols on their own.
One more issue -- you probably want to set time limits (alarm?) just in
case there might be infinite decision-making or communication loops.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: 28 Aug 2001 15:53:31 GMT
From: Jim Cook <jcook@strobedata.com>
Subject: Problems using Algorithm::Diff
Message-Id: <3B8BBE7A.49D27AA6@strobedata.com>
I've looked at the camel book, at "perldoc -q dereference" (which gives
nothing) and read all the pages from the camel book index about
dereference. I did "perldoc -m algorithm::diff" and read that.
I don't really understand this part of perl, so I'm asking for help.
My program
---------clip--------
#! perl -w
use strict;
use diagnostics; #-verbose;
use Algorithm::Diff;
print `perl -v`;
my @a = (1,2,3,4,5,6);
my @b = (2,3,4,5,6,7);
my $c = Algorithm::Diff::diff(\@a, \@b);
print $c;
---------clip--------
The output
---------clip--------
This is perl, v5.6.0 built for MSWin32-x86
Copyright 1987-2000, Larry Wall
Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5.0 source
kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to
the
Internet, point your browser at http://www.perl.com/, the Perl Home
Page.
ARRAY(0x85decec)
---------clip--------
So, I want to be able to find the differences between two large arrays,
and I've coded the simple test above to see if I can learn how to use
the diff function. I only get the ARRAY printed. When I've printed "@$c"
instead of just $c, I get ARRAY(0x85ded04)ARRAY(0x8ae2bb0) as the
output.
Could somebody replace the "print" statement with working code to show
the differences? Or, give me a good lesson in what the heck is being
returned and how I would use it.
I'm proficient in C and a beginner in perl. In understand the C
references, but am not able to apply that to perl for some reason.
Thanks in advance for any help offered.
--
jcook@strobedata.com Live Honourably 4/1 - 4/3 + 4/5 - 4/7 + . . .
2001 Wed: Feb/last 4/4 6/6 8/8/ 10/10 12/12 9/5 5/9 7/11 11/7 3/14
Strobe Data Inc. home page http://www.strobedata.com
My home page O- http://jcook.net
------------------------------
Date: 28 Aug 2001 11:13:59 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Problems using Algorithm::Diff
Message-Id: <87u1ys6u2g.fsf@limey.hpcc.uh.edu>
>> On 28 Aug 2001 15:53:31 GMT,
>> Jim Cook <jcook@strobedata.com> said:
> ---------clip--------
> #! perl -w
> use strict;
> use diagnostics; #-verbose;
>
> use Algorithm::Diff;
>
> print `perl -v`;
>
> my @a = (1,2,3,4,5,6);
> my @b = (2,3,4,5,6,7);
>
> my $c = Algorithm::Diff::diff(\@a, \@b);
>
> print $c;
> ---------clip--------
>
> So, I want to be able to find the differences between
> two large arrays, and I've coded the simple test above
> to see if I can learn how to use the diff function. I
> only get the ARRAY printed. When I've printed "@$c"
> instead of just $c, I get
> ARRAY(0x85ded04)ARRAY(0x8ae2bb0) as the output.
> Could somebody replace the "print" statement with
> working code to show the differences? Or, give me a good
> lesson in what the heck is being returned and how I
> would use it.
The value returned from diff is more complex than your
code assumes. perldoc says:
The description is a list of hunks; each hunk
represents a contiguous section of items which should
be added, deleted, or replaced. The return value of
"diff" is a list of hunks, or, in scalar context, a
reference to such a list.
Try using the Data::Dumper module, to see how perl stores
the result. Then look at this code:
use Algorithm::Diff qw(diff);
my @a = (1,2,3,4,5,6);
my @b = (2,3,4,5,6,7);
my @c = diff(\@a, \@b);
use Data::Dumper;
print Dumper(\@c);
foreach my $hunk (@c) { # list of hunks
foreach my $delta (@$hunk) { # is a list of changes
my ($op, $pos, $value) = @$delta;
print "$op at position $pos to $value\n";
}
}
$VAR1 = [ <-- list of hunks
[ <-- hunk
[ <-- line op
'-',
0,
1
]
],
[ <-- hunk
[ <-- line op
'+',
5,
7
]
]
];
- at position 0 to 1
+ at position 5 to 7
hth
t
--
Yes way! Mmmmkay?
------------------------------
Date: 28 Aug 2001 16:30:00 GMT
From: Jim Cook <jcook@strobedata.com>
Subject: Re: Problems using Algorithm::Diff
Message-Id: <3B8BC708.F6A6B757@strobedata.com>
> Try using the Data::Dumper module, to see how perl stores
> the result. Then look at this code:
> foreach my $hunk (@c) { # list of hunks
> foreach my $delta (@$hunk) { # is a list of changes
> my ($op, $pos, $value) = @$delta;
> print "$op at position $pos to $value\n";
> }
> }
Thank you! I didn't know about Data::Dumper.
I'll be able to take if from here. Thank you very much for you kind
help.
--
jcook@strobedata.com Live Honourably 4/1 - 4/3 + 4/5 - 4/7 + . . .
2001 Wed: Feb/last 4/4 6/6 8/8/ 10/10 12/12 9/5 5/9 7/11 11/7 3/14
Strobe Data Inc. home page http://www.strobedata.com
My home page O- http://jcook.net
------------------------------
Date: Tue, 28 Aug 2001 16:23:16 GMT
From: r1ckey@yahoo.com
Subject: Re: Profiling
Message-Id: <UzPi7.23538$sa.11889197@news1.rdc1.sfba.home.com>
NoNameBrand <mh2@isis.co.za> on Tue, 28 Aug 2001 10:37:25 +0200 wrote:
>Hi,
>I posted this to alt.perl as well, but wondered this group wouldn't be more
>appropriate...
>I have been wokring to rewrite some scripts, to reduce compile and excution
>time.
>Does anybody have any suggestions as to how I could go about timing these
>operations, in particular the load/compile time of a cgi, as well as the
>execution of the script? I would like to be able to compare the original to
>my changed versions, to get some stats about what improvements have been
>gained.
>I am running the latest Apache with ActiveState PERL on a Windows 98
>machine.
>Many thankx in advance...
The Benchmark module maybe what you're looking for...
--
____ __
______/_ | ____ | | __ ____ ___.__.
\_ __ \ |/ ___\| |/ // __ < | |
| | \/ \ \___| <\ ___/\___ |
|__| |___|\___ >__|_ \\___ > ____|
_________________\/_____\/____\/\/_____
---------------------------------------
------------------------------
Date: Tue, 28 Aug 2001 19:13:11 +0200
From: Valentin 30IR976 <radiotito@yahoo.com>
Subject: Quota module experts: I need your help
Message-Id: <3B8BD127.29576AC9@yahoo.com>
I am using Quota PErl module on RH Linux 7.0. I have quotas working fine
on my system, and would like to write a program in Perl that writes
different quota information of the users that have quotas working on my
system. Eg:
open PASSWD,"/etc/passwd";
while ($info=<PASSWD>)
{
($field1,$field2,...)= split (/:/, <PASSWD>); #using ':' as
separator
$field_uid= Quota::.....I call here the Quota module rutine to get
the quota information(soft/hard limits, etc...)
}
My code works if I want to check 1 user, and I write the login with
keyboard. But if I check the /etc/passwd looking for " users logins",
...How could I check if it is a proper user, and it has quotas enabled?,
and then, once checked this, print the quota information?...
Perhaps someone has made this before...
Thanks in advance from Tito
------------------------------
Date: Tue, 28 Aug 2001 08:09:34 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: REGEX
Message-Id: <3B8BB42E.F7FC6169@stomp.stomp.tokyo>
Fredrik Andersson wrote:
> Hi, I'm trying to use a REGEX for adding integers.
> I have a file with ascii text and are seaching for lines
> with the text POS_Z (se below)
> BUTTON_01 = SYMBOL /POS_Z = -770 /POS_Z = -950 /DATA=#1
> BUTTON_45 = SYMBOL /POS_Z = 570 /POS_Z = 320 /DATA=#1
> I want to add an integer to the number after the POS_Z =
> Say 20 =>
> BUTTON_01 = SYMBOL /POS_Z = -750 /POS_Z = -950 /DATA=#1
> BUTTON_45 = SYMBOL /POS_Z = 590 /POS_Z = 320 /DATA=#1
Your " Say 20 => " is not an integer. It is a character string.
These parameters of yours are very poorly stated and clearly
create confusion as to what you are trying to ask. You do not
qualify which numerical data set you want, or both. There is
no indication if your data is consistently in this exact format.
You indicate you want your data to be modified to:
"... POS_Z = Say 20 => ..."
Additionally, your article could be read to indicate you
want to add an integer to a number after the string:
"... POS_Z = Say 20 => ..."
Obviously, this string does not exist within your example.
I suspect neither of these examples is what you want.
In the future, work at writing clear, concise and coherent
articles before posting. It is very rude to expect help
from others, very rude to expect others to invest effort,
when you will not invest enough effort of your own to
write an article which is easy to read and makes sense.
A result of your posting an incoherent article, I have
elected to set parameters of my own. I am considering your
data to be consistent in format and, considering you want
both numerical data sets to manipulated mathematically,
not textually.
A slow memory wasteful regex may not be your best choice for this.
Godzilla!
--
#!perl
print "Content-type: text/plain\n\n";
$additive = 20;
while (<DATA>)
{
$number1 = substr ($_, index ($_, "Z = ") + 3, index ($_, " /") - rindex ($_, "= ") - 2);
print "Sum 1: ", $number1 + $additive, " ";
$number2 = substr ($_, rindex ($_, "= ") + 2, rindex ($_, " /") - rindex ($_, "= ") - 2);
print "Sum 2: ", $number2 + $additive, "\n";
}
__DATA__
BUTTON_01 = SYMBOL /POS_Z = -750 /POS_Z = -950 /DATA=#1
BUTTON_45 = SYMBOL /POS_Z = 590 /POS_Z = 320 /DATA=#1
PRINTED RESULTS:
________________
Sum 1: -730 Sum 2: -930
Sum 1: 610 Sum 2: 340
------------------------------
Date: Tue, 28 Aug 2001 08:42:34 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: REGEX
Message-Id: <3B8BBBEA.38CED46@stomp.stomp.tokyo>
Godzilla! wrote:
I need to provide my script final version.
Previously, I posted a stage development
rather than the final script version.
My erroneously posted stage development
script works ok but is not Perl perfect.
Godzilla!
--
#!perl
print "Content-type: text/plain\n\n";
$additive = 20;
while (<DATA>)
{
$number1 = substr ($_, index ($_, "Z = ") + 4, rindex ($_, " /P") - index ($_, "Z = ") - 4);
print "Sum 1: ", $number1 + $additive, " ";
$number2 = substr ($_, rindex ($_, "= ") + 3, rindex ($_, " /") - rindex ($_, "= ") - 3);
print "Sum 2: ", $number2 + $additive, "\n";
}
__DATA__
BUTTON_01 = SYMBOL /POS_Z = -750 /POS_Z = -950 /DATA=#1
BUTTON_45 = SYMBOL /POS_Z = 590 /POS_Z = 320 /DATA=#1
------------------------------
Date: Tue, 28 Aug 2001 16:36:19 -0000
From: darkon@one.net (David Wall)
Subject: Re: RegEx?
Message-Id: <Xns910B7FD0ED850darkononenet@207.126.101.97>
Samneric <samneric@tigerriverOMIT-THIS.com> wrote on 27 Aug 2001:
> Ilya Martynov wrote:
>> >>>>> Jason Baker said:
>> JB> firstname lastname <email@wherever.com>
>> JB> All I want to do is capture the name, not email address, into a
>> JB> variable.
>
>> my ($from) = $row->[1] =~ /(.*?)</;
>
> my ($from) = $row->[1] =~ /(.*?) </;
>
> Removes the space before "<" :)
As long as we're tweaking it,
my ($from) = $row->[1] =~ /^([^<]*) </;
is somewhat faster, as it doesn't have to backtrack as far. :-)
--
David Wall
darkon@one.net
------------------------------
Date: Tue, 28 Aug 2001 17:31:14 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Whence pmtools?
Message-Id: <CzQi7.733$V3.188635136@news.frii.net>
Back in the good old days (circa 1999) Tom Christiansen wrote a
wonderful set of command line tools for groping about for info in
the perl modules and libraries called pmtools. I read in a dead
but not forgotten TPJ that a version of the same, now apparently
called perlman, might have been included in te 5.6.1 release. That
seems not to have happened.
Cursory searches of all the usual suspects has exposed no warm
leads. Anyone have a pointer for me?
thanks
--
This space intentionally left blank
------------------------------
Date: 28 Aug 2001 17:05:24 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Will Perl report on variables no longer used??
Message-Id: <999017726.28618@itz.pp.sci.fi>
In article <slrn9omefs.r1r.abigail@alexandra.xs4all.nl>, Abigail wrote:
>Ilmari Karonen (iltzu@sci.invalid) wrote on MMCMXIX September MCMXCIII in
><URL:news:998960983.10957@itz.pp.sci.fi>:
>##
>## Well, the compiler certainly could be made to check for only-once-used
>## lexicals just as it currently checks for only-once-used globals. That
>## approach, of course, does produce both false positives and negatives.
>## It does not, to my knowledge, solve the halting problem.
>
>The "just as" isn't clear at all. The names of package variables live on,
>while they don't for lexicals.
Well, that could be changed, if it presents a problem. I'm not familiar
with that part of perl guts, so I can't say if it will. But if one is
willing to accept a solution that is only as good as what we currently
have for package variables, then the rest is a SMOP.
In any case, isn't the necessary information collected anyway, to allow
closures, string evals and redeclaration warnings?
------------------------------
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 1640
***************************************