[12129] in Perl-Users-Digest
Perl-Users Digest, Issue: 5729 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 19 21:07:19 1999
Date: Wed, 19 May 99 18:00:19 -0700
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, 19 May 1999 Volume: 8 Number: 5729
Today's topics:
Re: An /e for a match rather than a substitution <primrosesmith@magnet.at>
Re: An /e for a match rather than a substitution (Alan Curry)
Re: An /e for a match rather than a substitution (Larry Rosler)
Any concept of Constant in Perl <jalil@corp.home.net>
Re: Any concept of Constant in Perl (Larry Rosler)
Blasting array into hash ??? <mds-resource@mediaone.net>
Re: C superior to Perl in DB2 programming? (the other)
Re: Dynamic Naming of a Hash (Larry Rosler)
Example of using table_info with DBI <lynn@swcp.com>
File Opening Problem <frutchey@usc.edu>
HELP - Extracting META KEYWORDS script not working (Dave Taylor)
Re: How to make directory handles local? (Larry Rosler)
If possible, then how do I remove the last line in a te <limbeck@gte.net>
Log and redirection <efcoelho@123_rio.com>
Re: Log and redirection (Larry Rosler)
Re: Looking for Phonetic Program in Perl <cassell@mail.cor.epa.gov>
Re: Perl and Databases <cassell@mail.cor.epa.gov>
Re: Return Value from Sort subroutine (Larry Rosler)
search and fetch from newsgroup <yhu@mail.nih.gov>
search and fetch from newsgroup <yhu@mail.nih.gov>
search and fetch from newsgroup <yhu@mail.nih.gov>
search and fetch from newsgroup <yhu@mail.nih.gov>
search and fetch from newsgroup <yhu@mail.nih.gov>
Search and Fetch Newsgroup <yhu@mail.nih.gov>
Setting WinNT Registry Key Permissions via script <crazyg@texas.net>
Re: Y2K. localtime(time) (Alan Barclay)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 20 May 1999 01:29:21 +0200
From: "Steven Primrose-Smith" <primrosesmith@magnet.at>
Subject: Re: An /e for a match rather than a substitution
Message-Id: <7hvgrh$jmu$1@orudios.magnet.at>
Tad McClellan said:
> He said he was reading it in.
Yes, the string and the expression against which it must be
matched are read in at runtime at the command line. So
back to the original example, if someone enters the string as...
Mississippi
...and an expression...
Mis+s+p+i
...it needs to know whether there is a match.
> $string = "Mississippi";
> ^
> ^ the $expression cannot match that letter...
> Did you go fix the expression and try it?
> I think not!
> How come?
Have you calmed down now? What is wrong with
Mis+s+p+i as a match expression - it should match Mississippi
correctly (and Missssssisssssippppi, etc.) ?
> It does not appear as a literal in his code (of course we are
> all guessing here, since there wasn't any code provided).
>
> If he had given code showing it being read in, then I would
> have used that method. He didn't, so I didn't.
Forget the original code; I was trying (badly) to illustrate a
point. So how can the expression be matched with the string
if they are read in at runtime rather than provided as strings in
the code itself.
Steven
------------------------------
Date: Wed, 19 May 1999 23:43:46 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: An /e for a match rather than a substitution
Message-Id: <S0I03.811$Ie1.56164@news14.ispnews.com>
In article <7hvgrh$jmu$1@orudios.magnet.at>,
Steven Primrose-Smith <primrosesmith@magnet.at> wrote:
>
>Have you calmed down now? What is wrong with
>Mis+s+p+i as a match expression - it should match Mississippi
>correctly (and Missssssisssssippppi, etc.) ?
No, it doesn't. The + operator only matches repetitions of the atom preceding
it. "s+p+" matches some s's followed by some p's. Having an i in the middle
makes it not match.
>Forget the original code; I was trying (badly) to illustrate a
>point. So how can the expression be matched with the string
>if they are read in at runtime rather than provided as strings in
>the code itself.
The answer is you just put the variable in there and it works. Your sample
regexp is the only thing that's wrong.
$regexp = <STDIN>;
if("Mississippi" =~ /$regexp/) { ...
When you _don't_ want the string to be treated as a regexp, that's when you
have to do something special to it. That's what \Q...\E is for.
--
Alan Curry |Declaration of | _../\. ./\.._ ____. ____.
pacman@cqc.com|bigotries (should| [ | | ] / _> / _>
--------------+save some time): | \__/ \__/ \___: \___:
Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman
------------------------------
Date: Wed, 19 May 1999 17:44:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: An /e for a match rather than a substitution
Message-Id: <MPG.11acfadec0a4c22989ab7@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7hvgrh$jmu$1@orudios.magnet.at> on Thu, 20 May 1999 01:29:21
+0200, Steven Primrose-Smith <primrosesmith@magnet.at> says...
...
> Have you calmed down now? What is wrong with
> Mis+s+p+i as a match expression - it should match Mississippi
> correctly (and Missssssisssssippppi, etc.) ?
Sometimes posters get blind spots that are impenetrable.
/Mis+s+p+i/ does *not* match 'Mississippi'. There only two 'i's in the
regex to match against the four 'i's in 'Mississippi'. There haven't
been enough 'i's since the beginning of this thread.
> Forget the original code; I was trying (badly) to illustrate a
> point. So how can the expression be matched with the string
> if they are read in at runtime rather than provided as strings in
> the code itself.
Readily. Just chomp them if necessary, interpolate the regex string
into the regex, bind (=~) the regex to the string being matched, and
have a ball! Exactly as you did in your original post.
Of course, if the regex string is syntactically unsound, you will die
with a run-time error, but that can be handled with 'eval()'.
Of course, if the user is malicious, the regex string that is being
eval()-ed can tube your file system, but that is another matter.
Life is tough all over.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 19 May 1999 23:55:22 GMT
From: "Jalil Feghhi" <jalil@corp.home.net>
Subject: Any concept of Constant in Perl
Message-Id: <927158122.300751@zeppelin.svr.home.net>
Is there any way to define constants in Perl?
Thanks,
-Jalil
------------------------------
Date: Wed, 19 May 1999 17:47:10 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Any concept of Constant in Perl
Message-Id: <MPG.11acfb6745960b05989ab8@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <927158122.300751@zeppelin.svr.home.net> on Wed, 19 May 1999
23:55:22 GMT, Jalil Feghhi <jalil@corp.home.net> says...
> Is there any way to define constants in Perl?
That's a real toughie! RTFM.
perldoc constant
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 19 May 1999 19:53:37 -0500
From: "Michael D. Schleif" <mds-resource@mediaone.net>
Subject: Blasting array into hash ???
Message-Id: <37435D11.8AA0A35D@mediaone.net>
I am stumped. Hopefully, those of you smarter than me can enlighten me
this day ;)
If I have a simple array (@nodes), I know that I can blast it into an
hash in several ways:
[1] @nodes{@nodes} = ();
Now, I can test for existence of an element by name.
[2] @nodes{@nodes} = (1) x @nodes;
Now, I can use Boolean tests for existence.
[3] But, suppose that I want to assign another constant array as the
value to
each key in the new hash. Call this initialization of HOL . . .
for (@nodes) {
$nodes{$_} = ([1, 0, 1, 0]);
}
Although this works, it can be slower than necessary.
[4] Why *doesn't* this do what I thought it would do?
@nodes{@nodes} = ([1, 0, 1, 0]) x @nodes;
When complete, the following makes it look like I expect:
for (keys %nodes) {
print "$_ : @{ $nodes{$_} }\n";
}
[5] However, try this:
my @nodes = qw(mds abc 123 xyz 987); # sample data
@nodes{@nodes} = ([1, 0, 1, 0]) x @nodes;
@{ $nodes{987} }[3]++;
for (keys %nodes) {
print "$_ : @{ $nodes{$_} }\n";
}
Wow! Change one (1) instance of the fourth element of one row and the
fourth element of every row is also changed!
Clearly, I *do not* understand what these tricky array to hash
conversions
actually do.
Who can explain this in simple terms?
[6] I have settled on map, for now:
%nodes = map{ $_, ([1, 0, 1, 0]) } @nodes;
Is this the best solution? Is this the fastest, most efficient?
--
Best Regards,
mds
mds resource
888.250.3987
"Dare to fix things before they break . . . "
"Our capacity for understanding is inversely proportional to how much we
think we know. The more I know, the more I know I don't know . . . "
------------------------------
Date: Thu, 20 May 1999 00:41:20 GMT
From: "Bruce (the other) McCrea" <bruce2@home.com>
Subject: Re: C superior to Perl in DB2 programming?
Message-Id: <QSI03.9175$vP2.6358@news.rdc1.tn.home.com>
You need the DB2 SDK to build the module DBD::DB2.
To use the perl code on another machine, you'll need to copy the whole
/usr/local/lib/perl5 directory tree and /usr/local/bin/perl and whatever
gets installed when you install and compile perl or any module.
You should do this anyway. You will keep your perl run time environment
consistent throughout your enterprise.
The only limitation is that the destination machine architecture MUST
be the same as the source architecture. So you are limitted to any
IBM RS/6000 Power machine. IBM lets you copy your derived libraries
for nothing, which is good.
Hope this helps.
Tzadik Vanderhoof wrote in message <7hup3e$8vb$1@nnrp1.deja.com>...
>I'm quite surprised that I have gotten no response to this question
>(especially with such a provocotive subject :), so I'm reposting it.
>
>The customer allowed me to write this thing in Perl and is now
>regretting it, because it seems like it cannot be installed on a machine
>without the DB2 SDK, whereas had it been written in C, it would not have
>this problem. If this conclusion is wrong, PLEASE LET ME KNOW! If my
>conclusion is right, PLEASE LET ME KNOW! Thanks!
>
>Here is the original post:
>
>----------
>----------
>Is there any way I can distribute my Perl script that uses DBD::DB2 to
>machines that do not have the DB2 SDK installed?
>
>I know that the DB2 SDK is necessary to *build* DBD::DB2 but question
>why it should be necessary for simply *running* a script that *uses*
>DBD::DB2.
>
>One irritating aspect of this problem is that apparently a C program
>that uses DB2 does not suffer from this problem. You just "bind" the C
>program with the DB2 database (on a machine that has the DB2 SDK) and
>then you can distribute the compiled and "bound" C program to a machine
>that does *not* have the SDK. Thus if this is true, programming DB2 apps
>in C has a distinct advantage over programming them in Perl, which rubs
>me the wrong way.
>
>One problem with this issue is how to copy a DBD::DB2 module from one
>machine to the other (without building it on the second machine). I
>tried doing such a copy recently by simply using "tar" to package up the
>relavant directorys in /usr/local/lib/perl5, but I could not run my
>script on the second machine. I would get:
>
>Can't load
>/usr/local/lib/perl5/site_perl/5.005/aix/auto/DBD/DB2/DB2.so' for
>module DBD::DB2: dlopen:
>
>/usr/local/lib/perl5/site_perl/5.005/aix/auto/DBD/DB2/DB2 .so:
>A file or directory in the path name does not exist. at
>/usr/local/lib/perl 5/5.00502/aix/DynaLoader.pm line 168.
>
>(The "DB2.so" file it claims does not exist actually does exist...the
>problem seems to be something that is called from "DB2.so". The only
>way I could come up with to solve this problem was to install the DB2
>SDK on the second machine and rebuild DBD::DB2 there, which the customer
>does not want as a production solution. They do not want the SDK
>installed in production)
>
>
>--
>
>Thanks,
>
>Tzadik
>
>
>--== Sent via Deja.com http://www.deja.com/ ==--
>---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 19 May 1999 16:18:24 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Dynamic Naming of a Hash
Message-Id: <MPG.11ace6955576d498989ab3@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <927151332.992880@zeppelin.svr.home.net> on Wed, 19 May 1999
22:02:13 GMT, Jalil Feghhi <jalil@corp.home.net> says...
> Let' s assume I have two hash tables %X and %Y. I also have a scalar var in
> my program: $a which is either "X" or "Y". How can I make a hash var that
> points to my %X or %Y based on the value of $a. I dont want to do:
>
> if ($a eq "X") {
> # use %X
> }
> else{
> # use %Y
> }
>
> Rather, I like something like:
>
> %($a);
>
> Is there a way to do this?
Yes, but you don't want to do it that way! So-called 'symbolic
references' are harmful to the health of your program.
Keep the names of your variables in your own hash, rather than in the
global symbol table.
my %hashes = ( X => { ... hash X ... }, Y => { ... hash Y ... } );
# use %{$hashes{$a}} from now on ...
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 19 May 1999 17:09:22 -0600
From: "Lynn" <lynn@swcp.com>
Subject: Example of using table_info with DBI
Message-Id: <7hvgdn$dvb$1@sloth.swcp.com>
Could anyone share an example of perl code that prints the names of fields
in a database table. I'm confused on how to use table_info if that is the
correct way to approach this problem.
In particular, I've opened an MS-Access DB via ODBC and would like to
dynamically build SQL statements at runtime.
Examples would be appreciated....
Thanks,
Lynn
lynn@swcp.com
------------------------------
Date: Wed, 19 May 1999 15:19:28 -0700
From: Brian Frutchey <frutchey@usc.edu>
Subject: File Opening Problem
Message-Id: <374338F0.EDA084FE@usc.edu>
I was hoping someone could provide some insight to a very frustrating
problem.
I am using Perl 5.005_02, and have never had problems opening files for
writing
only before (ie, with >). But suddenly, all of my scripts which use
write mode
are giving me the error "Insecure dependency in open while running
setgid at
.../.../... line ...". I have determined that if I hardcode the
filename into
the code, the problem goes away, but this is not viable when the
filenames are
dynamically generated. I have to change the mode to +< to open a file
for
writing, then truncate it to 0 length manually before writing to it as a
workaround. Unfortunately, the problem is unsolvable if the file I wish
to
write to does not already exist. Could this be a problem with the
interpreter I
am using? I have tried two so far, and still the problem persists. Any
ideas?
--
____________________________________________________________________
_/_/_/ _/ _/ _/ _/ Brian Frutchey
_/ _/ _/ _/_/ _/ IHV Engineering
_/_/_/ _/ _/ _/ _/ _/ Alternate Platforms Group
_/ _/ _/ _/ _/_/ (310) 348-6082
_/_/_/ _/_/_/ _/ _/ http://www-scf.usc.edu/~frutchey
M I C R O S Y S T E M S
------------------------------
Date: Thu, 20 May 1999 00:54:38 GMT
From: taylor@netcom.com (Dave Taylor)
Subject: HELP - Extracting META KEYWORDS script not working
Message-Id: <taylorFC0AJ2.K3I@netcom.com>
I'm trying to write a Perl script that will let me feed in an arbitrary
page of HTML and pull out the CONTENTS of the meta keyword tag. The
line will look like:
<META NAME="keywords" CONTENT="x,y,z">
where any space could be a carriage return and the quotes might be
missing around the 'keywords' attribute rhs.
I thought I had it pegged with the following simple script, but the
results I get are blank rather than the matched CONTENT value. HELP!
% cat find-meta.pl
#!/usr/bin/perl
# first off, turn the entire file into one long line...
while (<>) {
chop;
$buf .= ' ' . $_;
}
# now let's extract the NAME=keywords information...
$buf =~ /name\s*=\s*"keywords"\s+content\s*=\s*=\s*"([^"]*)"/oi;
# print the matched buffer value
print "\n$1\n\n";
# and we're done.
exit 0
Here's the result of an invocation:
% lynx -source http://www.apple.com/ | find-meta.pl
%
If anyone can steer me in the right direction, I would be most
appreciative.
Thanks in advance.
-- Dave Taylor
taylor@intuitive.com
http://www.intuitive.com/
------------------------------
Date: Wed, 19 May 1999 17:05:50 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to make directory handles local?
Message-Id: <MPG.11acf1b8751661d6989ab4@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7hvd54$o2e$1@nnrp1.deja.com> on Wed, 19 May 1999 22:15:02
GMT, Anand <anand@my-dejanews.com> says...
> Perl beginner (reading "Learning Perl") asks:
A good start. And you didn't put 'newbie' in the title. Now start to
get acquainted with the Perl FAQ list.
> I am trying to write a recursive perl subroutine to print the unix
> directory tree. So the subroutine needs to recursively open directories.
> For this I need to make the directory handle (that I use in opendir)
> local. How do I do it?
...
> P.S: Here is my subroutine which will not work because the directory
> handle is not defined local:
>
> sub printdir {
> local($file,$pathname);
You want to use 'my' here, not 'local'.
> opendir(DIR,$_[0]) || die "opendir failed for $_[0]\n";
You want to include $! in the diagnostic.
> while ($file = readdir(DIR)) {
> $pathname = $_[0]."/$file";
You should indent the body of the loop, for readability. And writing
the last value as "$_[0]/$file" seems more natural than concatenating
it.
> if (-d $pathname && $file ne "." && $file ne "..") {
> print "$file\n";
> &printdir($pathname);
> }
> }
> closedir(DIR);
> }
You should read perlfaq5: "How can I make a filehandle local to a
subroutine? ..."
Another way to do this without having several directory handles open at
once is to read each directory completely before recursing:
my @dirs = readdir DIR;
closedir DIR;
and then loop over @dirs. That way you don't need local filehandles.
The File::Find module makes a lot of this much easier, but what you are
doing is a good way to learn.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 19 May 1999 23:42:17 GMT
From: "limbeck" <limbeck@gte.net>
Subject: If possible, then how do I remove the last line in a text file via CGI? (txt)
Message-Id: <t%H03.778$kw.30120@dfiatx1-snr1.gtei.net>
I use a script that adds one new line to a text file every time it is
executed via a form. I need it to remove the last line in that text file,
however, every time it adds a new one to the top (executes the script via
form).
So, how do I remove just the last line of a text file in CGI, if this is
possible?
Please forgive my ignorance... I know HTML well, and understand the concept,
but I still do *not* actually know CGI fully. I need to get a book some
time. :)
Thanks,
-Dolgan
------------------------------
Date: Wed, 19 May 1999 19:56:23 -0300
From: "Eng. Edilson Francioni Coelho" <efcoelho@123_rio.com>
Subject: Log and redirection
Message-Id: <37434197.E3D9FA83@123_rio.com>
Hi everyone,
I'm definitely a newbie, so forgive me for the question which I suppose
to be very elementary. I've been checking former messages but didn't
find related messages - except for one, which gave me a hint on the last
line of my script, which I don't know exactly why it works nor if it's
technically OK :-(
The objective is to write a log file which keeps track of "clicks" to a
link. I have substituted the "http://..." stuff for a link to the script
below, which worked fine in writing to the log file, except in that it
showed an error message in the browser.
#!/bin/perl
# -------------------------------------------------------------------
# Recording visitor data to file "cliques.txt":
$data_hora_sistema = localtime (time);
# date and time in the server
# (ex.: Mon Jan 26 11:03:40 1998)
@data_hora_sistema = split(/ /, $data_hora_sistema);
# separates the server's time string
# in its components
$data_sistema =
join('',@data_hora_sistema[2],@data_hora_sistema[1],substr(@data_hora_sistema[4],2,2));
# date in the format ddMmmaa
$hora_sistema = @data_hora_sistema[3];
# time in the format hh:mm:ss
$file = 'cliques.txt';
open(VISITS, ">>$file");
print (VISITS $data_sistema," ",$hora_sistema,"\nBrowser:
",$ENV{'HTTP_USER_AGENT'},"\nServer:",$ENV{'REMOTE_HOST'},"\n================\n");
close (VISITS);
I didn't know (as I still don't) why the error message appeared, but I
tried to do something about the redirection. I know I could make the
script generate an HTML file with a META tag which would send the
visitor to the final URL (or even generate the whole intended final
document, instead of redirecting the visitor to it), but I'd rather do
it directly. After browsing lots of messages in this newsgroup I finally
found one from which I have included the adapted (deeply cut) the last
line below:
# -------------------------------------------------------------------
# Redirection:
print "Location: http://.......\n\n";
The error message is finally gone and the script promotes redirection to
the page I want, but... although everything is apparently perfect, I
still don't know how it works in the 2 aspects below.
Please, could someone tell me:
1- Why do error messages appear if only the first part of the script is
used (writing to log file with no redirectioning)?
2- How does the last line work? Is "Location:" a PERL command I still
don't know about? Is it technically correct for doing the redirection I
want? If not, how should I have done it?
TIA
Edilson
(should anyone want to e-mail me, please change the "_" for "-" in my
domain name)
------------------------------
Date: Wed, 19 May 1999 17:30:35 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Log and redirection
Message-Id: <MPG.11acf78352b39451989ab6@nntp.hpl.hp.com>
In article <37434197.E3D9FA83@123_rio.com> on Wed, 19 May 1999 19:56:23
-0300, Eng. Edilson Francioni Coelho <efcoelho@123_rio.com> says...
<Big SNIP>
> # Redirection:
>
> print "Location: http://.......\n\n";
>
> The error message is finally gone and the script promotes redirection to
> the page I want, but... although everything is apparently perfect, I
> still don't know how it works in the 2 aspects below.
>
> Please, could someone tell me:
>
> 1- Why do error messages appear if only the first part of the script is
> used (writing to log file with no redirectioning)?
Because a CGI program *must* write something to the browser -- either a
redirection header as above, or a Content-Type header and some data.
> 2- How does the last line work? Is "Location:" a PERL command I still
> don't know about? Is it technically correct for doing the redirection I
> want? If not, how should I have done it?
It is an HTTP command and has nothing to do with Perl (which is the name
of the language, by the way, not PERL). It is correct.
And none of this post has anything to do directly with Perl. You have
made the usual beginner's errors in your code (no '-w'; no 'use
strict;';, no diagnostic on failure to open a file), and *those* have to
do with Perl. Fix them in each of your programs before posting here
again. :-)
> (should anyone want to e-mail me, please change the "_" for "-" in my
> domain name)
I would have been happy to e-mail you, had you changed the "_" for "-"
in your domain name.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 19 May 1999 17:01:19 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Looking for Phonetic Program in Perl
Message-Id: <374350CF.4F2786CA@mail.cor.epa.gov>
Spica wrote:
> [my snip of Effie Rover's question, and Ed Bogart's informed reply]
>
> I'm quite the perl newbie and I don't know anything about programming
> for this type of problem, but I seem to recall finding C/C++ Soundex
> algorithms on the web at one time (when I was looking for something
> else, actually). Is there such a thing already written for perl?
Yep. It's called the Text::Soundex module and it's mentioned
in the FAQ.
And it does *not* do what was requested. This is a common
misconception about soundex. After all, it 'sounds' like it
ought to do that. Soundex takes the first letter of the word,
then squashes the rest of the word into a tiny 3-digit
space. It does this by, in essence, throwing away all
the vowel information, and squishing together all
consonants/consonant-groups that sound vaguely alike. Sort
of. The Text::Soundex module is in plain Perl, and is very
easy to read. The actual implementation takes about 8 very
simple, easy-to-understand lines, with no one-linerism
or obfuscation around.
But soundex gives 'Kant' and 'Knuth' the same value.
'Ellery' and 'Euler' get the same value. Try these:
'oho!'
'Oy!!!!'
'oh-e-i-e-i-o...'
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 19 May 1999 17:34:21 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Perl and Databases
Message-Id: <3743588D.E2A2EDA6@mail.cor.epa.gov>
Jalil Feghhi wrote:
>
> Is there any database module in Perl (other that dbm)? For example, any way
> to interface with an Access (or any other) database on Windows?
You'll be pleased to learn that the DBI module works just fine
on win32 platforms. And DBD::* modules do too. They're avail-
able with no more effort than learning to use the ppm program
which comes with ActiveState Perl. The instructions are in
the HTML files that were installed automatically. For
Micro$oft Access, you'll probably want the DBD::ODBC module.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 19 May 1999 17:18:33 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Return Value from Sort subroutine
Message-Id: <MPG.11acf4b3b1a30147989ab5@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7hverb$pat$1@nnrp1.deja.com> on Wed, 19 May 1999 22:43:56
GMT, jj@versys.com <jj@versys.com> says...
> Have mercy, I am only beginning to learn about the wonderful world of
> Perl. i have never programmed previously and the _return_ value from
> the customized sort subroutines has me stumped. All the documention I
> have on this seems to assume that i am knowledgeable about this type of
> function. i am not.
You seem to be holding up fine!
> Does the subroutine evaluate every item in the
> list against every other item in the list?
The customized sort subroutine compares pairs of data, whose immediate
names are given by the special (package-)global variables $a and $b,
which are aliases for the actual variables being compared. The sort()
function supplies the pairs of data as necessary.
> How does the return _value_ re-order the data?
It tells the sort() function how to reorder the data.
> Is it just that the return value of -1,0,or 1
> determines which item should be where and it moves it appropriately (via
> the magic of Perl) and there is nothing more to know?
Essentially correct. 'It' that moves the items is the sort() function.
(For the comparison value, '< 0', 0, '> 0' is all that matters.)
> If so, then I
> guess I have answered my own question, otherwise any help would be
> appreciated. Thanks
I guess you have!
Gratuitous advice to beginners (not that you asked :-):
Use the '-w' flag on the first line (#!... -w) of every program.
Use 'use strict;' as the second line of every program.
Always check the return value of calls for operating-system functions
(specifically, the open() function), and include the $! variable in the
failure diagnostic.
...
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 19 May 1999 18:05:12 -0400
From: Ying Hu <yhu@mail.nih.gov>
Subject: search and fetch from newsgroup
Message-Id: <37433598.988A0558@mail.nih.gov>
Hi:
Which win32 module is with the function that can search newsgroups
and/or download some pieces of news from newsgroups by the subject?
For example, the perl script can search the Subject of comp.soft-sys.sas
with ANOVA key word and download the news (with ANOVA)
from the newsgroup.
Thanks!
Ying
------------------------------
Date: Wed, 19 May 1999 17:59:09 -0400
From: Ying Hu <yhu@mail.nih.gov>
Subject: search and fetch from newsgroup
Message-Id: <3743342C.D43A660A@mail.nih.gov>
Hi:
Which win32 module is with the function that can search newsgroup
and/or download some pieces of news from newsgroup?
For example, the perl script can search the Subject of comp.soft-sys.sas
with ANOVA key word and download the news (with ANOVA)
from the newsgroup.
Thanks!
Ying
------------------------------
Date: Wed, 19 May 1999 18:02:42 -0400
From: Ying Hu <yhu@mail.nih.gov>
Subject: search and fetch from newsgroup
Message-Id: <37433502.C305684@mail.nih.gov>
Hi:
Which win32 module is with the function that can search newsgroups
and/or download some pieces of news from newsgroups by the subject?
For example, the perl script can search the Subject of comp.soft-sys.sas
with ANOVA key word and download the news (with ANOVA)
from the newsgroup.
Thanks!
Ying
------------------------------
Date: Wed, 19 May 1999 18:09:31 -0400
From: Ying Hu <yhu@mail.nih.gov>
Subject: search and fetch from newsgroup
Message-Id: <3743369B.DC1C0139@mail.nih.gov>
Hi:
Which win32 module is with the function that can search newsgroups
and/or download some pieces of news from newsgroups by the subject?
For example, the perl script can search the Subject of comp.soft-sys.sas
with ANOVA key word and download the news (with ANOVA)
from the newsgroup.
Thanks!
Ying
------------------------------
Date: Wed, 19 May 1999 18:21:05 -0400
From: Ying Hu <yhu@mail.nih.gov>
Subject: search and fetch from newsgroup
Message-Id: <37433950.2E773C81@mail.nih.gov>
Hi:
Which win32 module is with the function that can search newsgroups
and/or download some pieces of news from newsgroups by the subject?
For example, the perl script can search the Subject of comp.soft-sys.sas
with ANOVA key word and download the news (with ANOVA)
from the newsgroup.
Thanks!
Ying
------------------------------
Date: Wed, 19 May 1999 18:36:36 -0400
From: Ying Hu <yhu@mail.nih.gov>
Subject: Search and Fetch Newsgroup
Message-Id: <37433CF4.BEC7875E@mail.nih.gov>
Hi:
Which win32 module is with the function that can search newsgroups
and/or download some pieces of news from newsgroups by the subject?
For example, the perl script can search the Subject of comp.soft-sys.sas
with ANOVA key word and download the news (with ANOVA)
from the newsgroup.
Thanks!
Ying
------------------------------
Date: Wed, 19 May 1999 19:08:00 -0500
From: "Greg Willis" <crazyg@texas.net>
Subject: Setting WinNT Registry Key Permissions via script
Message-Id: <OoI03.14400$5e2.298834@news2.giganews.com>
Does any one know how I would go about changing permissions on registry keys
via a script? I know how to change these entries from the GUI.
I have not been able to find any documentation in the Win32::Registry
module.
Thanks
------------------------------
Date: 19 May 1999 23:07:57 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: Y2K. localtime(time)
Message-Id: <927155269.902070@elaine.drink.com>
In article <MPG.11acabf6925c5e28989aae@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>The only one I have used (actually, passed on to a non-Perl-programmer
>to use) is formmail, which simply accepts CGI input from a static HTML
>form and generates e-mail with the form's field contents. The
>'sendmail' address is probably hard-wired into the program.
>
>In addition to being '-w' and 'use strict;' intolerant, this script does
>inadequate error checking. That is probably typical of all of the
>scripts. But the 'logic' of this particular dummy is probably adequate,
>and maybe for all of them. After all, they are supposed to be
>functional, no?
It's also very trivial to use this script to send 3rd party emails
(eg for spam).
The only security check is on the referer, and we know how easy this is
to fake. Once you've done that, you can set the to address to be anything
you want, and sent essentially untraceable email until the cows come home.
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 5729
**************************************