[22187] in Perl-Users-Digest
Perl-Users Digest, Issue: 4408 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 15 11:06:25 2003
Date: Wed, 15 Jan 2003 08:05:06 -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 Wed, 15 Jan 2003 Volume: 10 Number: 4408
Today's topics:
Re: Matching entries in lists (Bernd Schandl)
Re: newbie: Tk questions (a sensible and a stupid one) <lusol@Pandora.cc.lehigh.edu>
Re: newbie: Tk questions (a sensible and a stupid one) <olafdonk@wanadoo.nlQQQ>
Re: newbie: Tk questions (a sensible and a stupid one) <olafdonk@wanadoo.nlQQQ>
Re: newbie: Tk questions (a sensible and a stupid one) (Tad McClellan)
Re: newbie: Tk questions (a sensible and a stupid one) <olafdonk@wanadoo.nlQQQ>
Re: newbie: Tk questions (a sensible and a stupid one) <spikey-wan@bigfoot.com>
Re: Perl and Ruby <usenet@dwall.fastmail.fm>
Problem with DBI (Jason Singleton)
Re: Question about high performance spidering in perl ctcgag@hotmail.com
Re: Question about high performance spidering in perl (Peter Scott)
Re: Renaming files *.txt to 1234.txt (tî'pô)
Re: return value of backticks under DOS (Chas Friedman)
sysopen problem <neil@alaweb.com>
Re: sysopen problem (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Jan 2003 08:04:09 -0800
From: schandl@gmx.net (Bernd Schandl)
Subject: Re: Matching entries in lists
Message-Id: <7b52b64e.0301150804.3192498f@posting.google.com>
schandl@gmx.net (Bernd Schandl) wrote in message news:<7b52b64e.0301100655.1a7035c3@posting.google.com>...
> I have the following problem: I have a list where each entry is a telephone
> number, a name and a category. In a second list, I have telephone numbers
> (in the same format) and I want to check whether they appear in the first
> list and if yes, what the corresponding name and category is. As an
> additional difficulty, the numbers in the first list are not necessarily
> complete numbers but rather the beginning of a telephone number (think area
> code or company). So for the entry 12345678 in the second list, I want to be
> able to find the entry (123,"Some company","work") in the first list. I only
> need to find the first match.
>
> So my questions are:
> - What is the best data structure for the first list? Some kind of array?
> Two hashes?
> - What is a good/efficient/elegant way to find an entry in the first list
> matching a number from the second?
Thanks a lot for the lively discussions. After considering what I read here
and in a German newsgroup and thinking a bit by myself (!), I settled on the
following solution. Assuming I have the first list in a hash %numcat,
I wrote the following routine, which gets a number from the second list as
an argument and returns a hash key (or undef if no fitting entry is found):
sub findkey {
my ( $number ) = @_;
for ( keys( %numcat ) ) { if ( $number =~ /^$_/ ) { return $_ } }
return undef;
}
This way I only do one comparison per hash entry. I did not bother to
implement something like binary search through the hash because both of my
lists have only something like 50 entries.
Comments are welcome. Thanks again.
Bernd
------------------------------
Date: 15 Jan 2003 14:10:06 GMT
From: "Stephen O. Lidie" <lusol@Pandora.cc.lehigh.edu>
Subject: Re: newbie: Tk questions (a sensible and a stupid one)
Message-Id: <b03q3u$fuq@fidoii.CC.Lehigh.EDU>
olaf <olafdonk@wanadoo.nl> wrote:
> And as for the stupid question: In order to solve my riddle myself I'm
> reading the Tk::UserGuide. It strongly recommends running the widget demo
> but I can't find the thing. Is it part of the standard Perl/Tk
> distribution? Does anybody know were to find it?
It should be in your default path on both Unix and Win32, so just type
"widget" at a command prompt.
> Thanks for any help, if I'm asking at the wrong place (I'm aware of
> c.l.p.tk, but it doesn't seem to have a lot of traffic...) or should do
> more homework before bothering you, just say so ;-)
You should be asking in compl.lang.perl.tk, of course (;
Steve
--
@_=map{eval"100${_}"}split/!/,'/5!*2!+$]!/10+$]';use Tk;$m=tkinit;$t='just an'.
'other perl hacker';$z='createText';$c=$m->Canvas(-wi,$_[1],-he,25)->grid;$c->$
z(@_[2,3],-te,$t,-fi,'gray50');$c->$z($_[2]-$],$_[3]-$],-te,$t);$m->bind('<En'.
'ter>',sub{$y=int(rand($m->screenheight));$m->geometry("+$y+$y")});MainLoop;
------------------------------
Date: Wed, 15 Jan 2003 16:26:38 +0100
From: olaf <olafdonk@wanadoo.nlQQQ>
Subject: Re: newbie: Tk questions (a sensible and a stupid one)
Message-Id: <pan.2003.01.15.15.26.36.912901.1337@wanadoo.nlQQQ>
On Wed, 15 Jan 2003 15:10:39 +0100, olaf wrote:
> Hi all,
>
> i want to create a 8x8 array of buttons, but I'm having trouble
> understanding the pack manager. If anybody has a suggestion...
>
> And as for the stupid question: In order to solve my riddle myself I'm
> reading the Tk::UserGuide. It strongly recommends running the widget
> demo but I can't find the thing. Is it part of the standard Perl/Tk
> distribution? Does anybody know were to find it?
>
> Thanks for any help, if I'm asking at the wrong place (I'm aware of
> c.l.p.tk, but it doesn't seem to have a lot of traffic...) or should do
> more homework before bothering you, just say so ;-)
>
> Olaf
ok, thanks! just typing 'widget' at the prompt works indeed.
Stupid questions, stupid answers, LOL
------------------------------
Date: Wed, 15 Jan 2003 16:28:11 +0100
From: olaf <olafdonk@wanadoo.nlQQQ>
Subject: Re: newbie: Tk questions (a sensible and a stupid one)
Message-Id: <pan.2003.01.15.15.28.11.366288.1337@wanadoo.nlQQQ>
On Wed, 15 Jan 2003 14:48:02 +0100, Josef Möllers wrote:
> olaf wrote:
>>
>> Hi all,
>>
>> i want to create a 8x8 array of buttons, but I'm having trouble
>> understanding the pack manager. If anybody has a suggestion...
>
> As usual, TMTOWTDI:
TM????
> 1. you can create a vertical frame of horizontal frames of buttons. Pack
> the bittons -side=left and the horizontal frames -side=top.
> Disadvantage: the buttons will, in general, have different sizes.
can that be avoided?
> 2. you can use the grid manager: man Tk::grid, e.g. $button->grid(-row
> => $row, -column => $col);
I'll try both, thanks, Olaf
------------------------------
Date: Wed, 15 Jan 2003 09:09:35 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: newbie: Tk questions (a sensible and a stupid one)
Message-Id: <slrnb2audf.bi4.tadmc@magna.augustmail.com>
olaf <olafdonk@wanadoo.nlQQQ> wrote:
> On Wed, 15 Jan 2003 14:48:02 +0100, Josef Möllers wrote:
>> As usual, TMTOWTDI:
>
> TM????
"There's More Than One Way To Do It"
Also mentioned in "Is Perl difficult to learn?" in perlfaq1.pod.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 15 Jan 2003 17:28:45 +0100
From: olaf <olafdonk@wanadoo.nlQQQ>
Subject: Re: newbie: Tk questions (a sensible and a stupid one)
Message-Id: <pan.2003.01.15.16.28.45.898155.1337@wanadoo.nlQQQ>
On Wed, 15 Jan 2003 16:09:35 +0100, Tad McClellan wrote:
> olaf <olafdonk@wanadoo.nlQQQ> wrote:
>> On Wed, 15 Jan 2003 14:48:02 +0100, Josef Möllers wrote:
>
>>> As usual, TMTOWTDI:
>>
>> TM????
>
>
> "There's More Than One Way To Do It"
ah
> Also mentioned in "Is Perl difficult to learn?" in perlfaq1.pod.
read en reread it, but can't remember everything :-)
------------------------------
Date: Wed, 15 Jan 2003 15:53:52 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Re: newbie: Tk questions (a sensible and a stupid one)
Message-Id: <b04083$aot$1@newshost.mot.com>
"olaf" <olafdonk@wanadoo.nlQQQ> wrote
> > 1. you can create a vertical frame of horizontal frames of buttons. Pack
> > the bittons -side=left and the horizontal frames -side=top.
> > Disadvantage: the buttons will, in general, have different sizes.
>
> can that be avoided?
Yes.
my $button = $frame -> Button (
-text => 'A button',
-background => 'light grey',
-activebackground => 'grey',
-borderwidth => '5',
-width => '30',
-relief => 'raised',
-state => 'normal',
-command => \&do_something,
)
-> pack ();
my $button1 = $frame -> Button (
-text => 'Another button',
-background => 'light grey',
-activebackground => 'grey',
-borderwidth => '5',
-width => '30',
-relief => 'raised',
-state => 'normal',
-command => \&do_something_else,
)
-> pack ();
R.
------------------------------
Date: Wed, 15 Jan 2003 14:55:09 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Perl and Ruby
Message-Id: <Xns930464E732A5Adkwwashere@216.168.3.30>
Jürgen Exner <jurgenex@hotmail.com> wrote on 11 Jan 2003:
> I just read a magazine article about Ruby and I was wondering if some
> Perlers have any experience with that language.
> How does it compare to Perl? Where are the individual strengths and
> weaknesses of each language when compared to each other?
I've not used Ruby myself, but I happened to run across a page
discussing it at Ward Cunningham's wiki, by coincidence at around the
time of your post: http://c2.com/cgi/wiki?RubyLanguage
ObPerl: I also made some additions to the Perl page
<http://c2.com/cgi/wiki?PerlLanguage> on that wiki while I was there.
Changed comp.lang.perl to comp.lang.perl.misc, and added a reference to
the posting guidelines.
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: 15 Jan 2003 07:16:08 -0800
From: jsn@microlib.demon.co.uk (Jason Singleton)
Subject: Problem with DBI
Message-Id: <5b7e0283.0301150716.28f2f0db@posting.google.com>
Can't locate auto/DBI/prepare.al in @INC (@INC contains: C:/Perl/lib
C:/Perl/site/lib . C:/Apache2/cgi-bin/WebOPAC/packages) at
drivers/text.pl line 27 Compilation failed in require at
C:/Apache2/cgi-bin/WebOPAC/webopac.cgi line 69.
Not sure on how to deal with that error, I'm trying to use
DBD::AnyData and get this error on the prepare statment.
------------------------------
Date: 15 Jan 2003 15:46:53 GMT
From: ctcgag@hotmail.com
Subject: Re: Question about high performance spidering in perl
Message-Id: <20030115104653.173$SL@newsreader.com>
Extended Partition <extendedpartition@NOSPAM.yahoo.com> wrote:
>
> I am looking at a project that aims to create a high performance
> spider program to assist in internet searches. Actually, it's really a
> combo program that combines spider and search agent technology
> together if that makes any difference.
This sounds like a bad idea. Do us all a favor and use google.
> The program will basicaly crawl
> the web (starting at an abitrary URI)
Hopefully a URI internal to your organization, that stays there.
> and search pages for specific
> target words. If it finds a target word or phrase on a page then it
> will save that page to a db.
You had better save that page to a db whether it has the word or phrase
or not, or you will get stuck in an infinite loop.
> If not, it moves to the next page. In
> addition, it needs to link out from each page to every page the
> current page links to.
Someone is going to interpret this as a DOS attack and nuke you.
> It needs to do this over and over and over. In
> effect "crawl" the web. My question is NOT how to do this as I have a
> good understanding of what it needs to do. My question rather is
> "should I use Perl to do it"?
If I were to do this in the first place, I'd use Perl and Mysql
(or some fancier rdbms, if you have one.).
I'd make Mysql handle most of the concurrency issues.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: Wed, 15 Jan 2003 16:03:49 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: Question about high performance spidering in perl
Message-Id: <FDfV9.40782$sV3.2253912@news3.calgary.shaw.ca>
In article <j9q82v8qtrqanmgpfs3bb4jv0mrtcv91r1@4ax.com>,
Extended Partition <extendedpartition@NOSPAM.yahoo.com> writes:
>Hello Everyone,
>
>I am looking at a project that aims to create a high performance
>spider program to assist in internet searches. Actually, it's really a
>combo program that combines spider and search agent technology
>together if that makes any difference. The program will basicaly crawl
>the web (starting at an abitrary URI) and search pages for specific
>target words. If it finds a target word or phrase on a page then it
>will save that page to a db. If not, it moves to the next page. In
>addition, it needs to link out from each page to every page the
>current page links to. It needs to do this over and over and over. In
>effect "crawl" the web. My question is NOT how to do this as I have a
>good understanding of what it needs to do. My question rather is
>"should I use Perl to do it"?
Why don't you use a package that's already been written - in Perl - to
do what you want? Use Harvest-NG, a powerful open source spidering
and indexing system. http://webharvest.sourceforge.net/ng/.
--
Peter Scott
http://www.perldebugged.com
------------------------------
Date: Wed, 15 Jan 2003 17:20:30 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: Renaming files *.txt to 1234.txt
Message-Id: <b1va2vov1stfaa7i6edfa0fbajfhn1sqn0@4ax.com>
Bernard El-Hagin bravely attempted to attach 24 electrodes of
knowledge
to the nipples of comp.lang.perl.misc by saying:
>In article <3E254E67.6D2926BC@fujitsu-siemens.com>, Josef Möllers wrote:
>> Paul Tomlinson wrote:
>>>
>>> Renaming files *.txt to 1234.txt
>>>
>>> Hello,
>>>
>>> I need to rename every .txt file in a directory to 1234.txt. I understand
>>> that this will cause some files to get overridden, but this is ok. Is there
>>> any one line expression that will do this sort of thing for me?
>>
>> map { rename $_, "1234.txt" } (<*.txt>);
>
>
>Or:
>
>
> rename $_, '1234.txt' for glob('*.txt');
Or:
my @tmp = glob('*.txt');
rename splice(@tmp, rand @tmp, 1), '1234.txt' if @tmp;
unlink @tmp;
This isn't one line but it has the added advantage of your not being
able to know in advance which file you're keeping and which you're
losing ;o)
------------------------------
Date: Wed, 15 Jan 2003 15:38:44 +0000 (UTC)
From: friedman@math.utexas.edu (Chas Friedman)
Subject: Re: return value of backticks under DOS
Message-Id: <b03va4$lds$1@geraldo.cc.utexas.edu>
__________
You wrote:
.............
>Chas, don't listen to me. I'm insane.
>KP
No problem, I've been insane for years!
cf
------------------------------
Date: Wed, 15 Jan 2003 08:12:07 -0600
From: "Neil Trenholm" <neil@alaweb.com>
Subject: sysopen problem
Message-Id: <v2ar1lm6qe7qd3@corp.supernews.com>
Hi,
Here is my perl -v output ... or the relevant bits anyhow...
-----
This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2001, Larry Wall
Binary build 631 provided by ActiveState Tool Corp.
http://www.ActiveState.com
Built 17:16:22 Jan 2 2002
-----
running on a Win2K Server.
This line
sysopen(FH, $logfile, O_RDWR|O_CREAT) or die "can't open $logfile: $!";
produces this error...
Argument "O_SVWST" isn't numeric in sysopen at
E:/Perl/site/lib/CreateYourWeb/Logger.pm line 91.
can't open E:/admin/logs/test.log: No such file or directory at
E:/Perl/site/lib/CreateYourWeb/Logger.pm line 91.
I have strict and warnings turned on.
I am using sysopen as per the FAQ on file locking, which suggests something
similiar to...
use Fcntl;
sysopen(FH, "numfile", O_RDWR|O_CREAT, 0644) or die "can't open numfile:
$!";
flock(FH, 2) or die "can't flock
numfile: $!";
$num = <FH> || 0;
seek(FH, 0, 0) or die "can't rewind
numfile: $!";
truncate(FH, 0) or die "can't truncate
numfile: $!";
(print FH $num+1, "\n") or die "can't write
numfile: $!";
# DO NOT UNLOCK THIS UNTIL YOU CLOSE
close FH or die "can't close
numfile: $!";
Thanks for any help,
Neil
------------------------------
Date: 15 Jan 2003 15:07:47 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: sysopen problem
Message-Id: <b03tg3$c7l$2@mamenchi.zrz.TU-Berlin.DE>
Neil Trenholm <neil@alaweb.com> wrote in comp.lang.perl.misc:
> Hi,
>
> Here is my perl -v output ... or the relevant bits anyhow...
> -----
> This is perl, v5.6.1 built for MSWin32-x86-multi-thread
> (with 1 registered patch, see perl -V for more detail)
>
> Copyright 1987-2001, Larry Wall
>
> Binary build 631 provided by ActiveState Tool Corp.
> http://www.ActiveState.com
> Built 17:16:22 Jan 2 2002
> -----
>
> running on a Win2K Server.
>
> This line
>
> sysopen(FH, $logfile, O_RDWR|O_CREAT) or die "can't open $logfile: $!";
>
> produces this error...
>
> Argument "O_SVWST" isn't numeric in sysopen at
Googling for "O_SVWST" appears to show that this problem has been
encountered before (in a Perl context). I didn't follow through
to a possible solution, but I suppose there is one.
(Our own Bart Lateur appears to have asked about this on some forum in
1998, so there has been time.)
Anno
------------------------------
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 4408
***************************************