[10935] in Perl-Users-Digest
Perl-Users Digest, Issue: 4536 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 3 10:07:22 1999
Date: Sun, 3 Jan 99 07:00:20 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 3 Jan 1999 Volume: 8 Number: 4536
Today's topics:
a server being able to dintinguish multiple instances o howhow@dbworld.net.au
Re: Adding a path to the @INC variable (Bart Lateur)
Re: Adding a path to the @INC variable <ltl@rgsun40.viasystems.com>
Re: Any NIS+ Perl Modules? (Clay Irving)
Re: Bug in Modulo Operator? (Ilya Zakharevich)
Re: Bug in Modulo Operator? <skilchen@swissonline.ch>
Re: Bug in Modulo Operator? (David Formosa)
Re: Converting globs to regexes (was: wildcard) (Tye McQueen)
Re: Crypt() (Mark Badolato)
Re: EXPERIENCED IN PERL ? <ebohlman@netcom.com>
Re: Formatting Dates (Searching for date + 30) <ebohlman@netcom.com>
Is interpolation/parsing in s/// possible? (Mark Badolato)
Re: Is interpolation/parsing in s/// possible? <gellyfish@btinternet.com>
Re: locating module GDBM_File <r_larsen@image.dk>
Lockfile in CPAN <webmaster@mcomn.com>
Re: Newbie - OPEN() gives sh error - why? <gellyfish@btinternet.com>
Re: noop (Bart Lateur)
Re: noop (David Formosa)
Re: noop <jhi@alpha.hut.fi>
Re: Path under windows <ebohlman@netcom.com>
Re: Problem with read and eof (Bart Lateur)
Re: Problem with read and eof <gellyfish@btinternet.com>
Re: Problem with read and eof <r_larsen@image.dk>
Re: Reading comma delimited files <ebohlman@netcom.com>
Re: Reading comma delimited files <r_larsen@image.dk>
Server misconfiguration error <msantull@dimensione.com>
Re: Server misconfiguration error <gellyfish@btinternet.com>
uppercase imchat@ionet.net
Re: uppercase <ebohlman@netcom.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 03 Jan 1999 14:18:35 GMT
From: howhow@dbworld.net.au
Subject: a server being able to dintinguish multiple instances of the same process
Message-Id: <76nu7q$p2l$1@nnrp1.dejanews.com>
Suppose there is a server process running on host1, listening to a particular
port, say port 1234, then forks out child processes to handle requests.
This server is used to handle the requests from an application on PC. Since
each PC has different IP address in a LAN, each PC can has its own socket to
talk to the server.
I tried to write a Perl script to simulate multiple instances of a PC
application talking to the server. I will run these Perl script serveral times
on the *SAME* host concurrently. I found out that while the first process is
running, if a second process is started, the first process will get "broken
pipe".
I want the server be able to distinguish different instances of the same
script on the same host. (I ran the same script on different hosts and it
worked fine.)
Here are the codes:
Note that there is a while loop to keep the script running.
#!/usr/local/bin/perl
$AF_UNIX = 1;
$AF_INET = 2;
# Port used by Server
$port = 1234;
$serverhost = "host2";
$clienthost = `uname -n`;
chop $clienthost;
($name,$alias,$protocol) = getprotobyname("tcp");
($d1,$d2,$d3,$d4,$rawclient) = gethostbyname($clienthost);
($d1,$d2,$d3,$d4,$rawserver) = gethostbyname($serverhost);
print "$clienthost -------> $serverhost\n\n";
$clientaddr = pack("Sna4x8", $AF_INET, 0, $rawclient);
$serveraddr = pack("Sna4x8", $AF_INET, $port, $rawserver);
print "PID = $$\n";
socket(SOCK, $AF_INET,1,$protocol) || die (". No socket");
bind(SOCK,$clientaddr) || die (". No socket");
$result = connect(SOCK, $serveraddr);
if($result!=1) {
print ". Failed to connect to socket\n";
die "Bye~~";
}
else {
print ". Connect to socket successfully\n";
}
select(SOCK);
$| = 1;
select(STDOUT);
$| = 1;
####################################################################
while(1) {
# Login request to server
$send = "login";
print "$clienthost --> $serverhost [$send]\n";
print SOCK $send;
read(SOCK,$recv,1);
print "$clienthost <-- $serverhost [$recv]\n";
# LOGOUT request to server
$send = "logout";
print "$clienthost --> $serverhost [$send]\n";
print SOCK $send;
read(SOCK,$recv,1);
print "$clienthost <-- $serverhost [$recv]\n";
}
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Sun, 03 Jan 1999 12:35:35 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Adding a path to the @INC variable
Message-Id: <368f5aa1.1206098@news.skynet.be>
Daniel Grisinger wrote:
>They do differ semantically, though. Your method pushes the
>additional directory on the end of your search path, use lib shifts
>the directory onto the front of the path. A minor difference, but
>hell to debug if you get bitten.
Then
BEGIN {
unshift @INC,'/path/to/private/lib';
}
will do the same.
Bart.
------------------------------
Date: 3 Jan 1999 13:41:26 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: Adding a path to the @INC variable
Message-Id: <76ns26$coi$1@rguxd.viasystems.com>
Uri Guttman <uri@home.sysarch.com> wrote:
:>>>>>> "PLB" == Peter L Berghold <peter@berghold.net> writes:
:> PLB> BEGIN {
:> PLB> push(@INC,"/some/path/some/where");
:> PLB> }
:> PLB> that will work as well. I still use that method over the use
:> PLB> library '/some/where/over/the/rainbow' method because everything
:> PLB> between BEGIN{ and } gets executed before the interpreter
:> PLB> executes the rest of the code. I use this especially where I
:>so does use lib. it is basically the same thing as use lines are
:>executed at compile time just as BEGIN blocks are.
:>but use lib is more compact and descriptive so it wins over the BEGIN
:>method.
Pushing onto the end of @INC allows overriding the include
path with the -I command line switch or the PERL5LIB variable. You
snipped that out of PLB's post. With "use lib" or unshifting onto
the front of @INC in the BEGIN block I have not found any way to
override the library path from the command line for testing a new
version of a module. Is there a way to do that? I tried "-I 'whatever'"
and PERL5LIB environmental variable, but both are interpreted before
the BEGIN block and "use lib" directives.
--
// Lee.Lindley | There was a time when I thought that "being right"
// @bigfoot.com | was everything. Then I realized that getting along
// | was more important. Still, being right is more fun!
// | And if I'm wrong, somebody will get some joy out of telling me!
------------------------------
Date: 3 Jan 1999 09:39:44 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Any NIS+ Perl Modules?
Message-Id: <76nvfg$rhu@panix.com>
In <368EE621.8E5B62B4@berghold.net> "Peter L. Berghold" <peter@berghold.net> writes:
>"Paul Virgo.RMS.23/S411.x67878" wrote:
>> I would like to write some web-based NIS+ apps in Perl and was wondering
>> if there are any pre-written NIS+ modules I can download? Thanks in advance.
>Paul,
>Check out the CPAN site www.cpan.org. I know that I saw one there, but I'm
>not sure how functional it is.. I know it is still in BETA. (or was it
>Alpha???)
Watch this:
# perl -MCPAN -e shell
cpan shell -- CPAN exploration and modules installation (v1.43)
ReadLine support enabled
cpan> i /NIS/
CPAN: LWP loaded ok
Fetching with LWP:
ftp://ftp.cdrom.com/pub/perl/CPAN/authors/01mailrc.txt.gz
Going to read /net/local/src/CPAN/sources/authors/01mailrc.txt.gz
Fetching with LWP:
ftp://ftp.cdrom.com/pub/perl/CPAN/modules/02packages.details.txt.gz
Going to read /net/local/src/CPAN/sources/modules/02packages.details.txt.gz
Scanning cache /net/local/src/CPAN/build for sizes
Fetching with LWP:
ftp://ftp.cdrom.com/pub/perl/CPAN/modules/03modlist.data.gz
Going to read /net/local/src/CPAN/sources/modules/03modlist.data.gz
Author DENWA (Dennis Watson)
Author FIMM (Dennis Taylor)
Author SMALYSHEV (Stanislav Malyshev)
Author WSANNIS (William S. Annis)
Distribution D/DE/DEP/Apache-AuthenNIS-0.10.tar.gz
Distribution D/DE/DEP/Apache-AuthzNIS-0.10.tar.gz
Distribution IKETRIS/Net-NISplusTied-0.02.tgz
Distribution RIK/NIS-a2.tar.gz
Distribution RIK/NISPlus-0.06-alpha.tar.gz
Distribution V/VA/VALERIE/Apache-AuthenNISPlus-0.03.tar.gz
Module Apache::AuthenNIS (D/DE/DEP/Apache-AuthenNIS-0.10.tar.gz)
Module Apache::AuthenNISPlus (V/VA/VALERIE/Apache-AuthenNISPlus-0.03.tar.gz)
Module Apache::AuthzNIS (D/DE/DEP/Apache-AuthzNIS-0.10.tar.gz)
Module CGI::MiniSvr (LDS/CGI-modules-2.76.tar.gz)
Module Net::NIS (RIK/NIS-a2.tar.gz)
Module Net::NIS::Table (RIK/NIS-a2.tar.gz)
Module Net::NISPlus (RIK/NISPlus-0.06-alpha.tar.gz)
Module Net::NISPlus::Directory (RIK/NISPlus-0.06-alpha.tar.gz)
Module Net::NISPlus::Entry (RIK/NISPlus-0.06-alpha.tar.gz)
Module Net::NISPlus::Group (RIK/NISPlus-0.06-alpha.tar.gz)
Module Net::NISPlus::Object (RIK/NISPlus-0.06-alpha.tar.gz)
Module Net::NISPlus::Table (RIK/NISPlus-0.06-alpha.tar.gz)
Module Net::NISplusTied (IKETRIS/Net-NISplusTied-0.02.tgz)
--
Clay Irving
clay@panix.com
------------------------------
Date: 3 Jan 1999 10:21:11 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Bug in Modulo Operator?
Message-Id: <76ngan$n1u$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<tchrist@mox.perl.com>],
who wrote in article <76n0d0$pd4$1@csnews.cs.colorado.edu>:
>
> In comp.lang.perl.misc,
> "Samuel Kilchenmann" <skilchen@swissonline.ch> writes:
> :If this is "normal" Perl behavior: where can i find a
> :description/specification of the differences in the precision limits
> :between the modulo operator and "normal" arithmetic operations?
>
> So long as you restrict yourself to integers whose abosulute
> values are no greater than 2**31, you shouldn't have any surprises.
> Beyond that, and you get get to deal with the flakinesses of floating
> point numbers, which by and large, only those who took a numerical
> analysis class and bothered to pay attention seem to understand.
This time you are wrong. These problems have nothing to do with
flakiness of doubles when representing real number. Perl arithmetic
was not well thought through, which gave a horrible implementation.
The numerous bugs/features can make the same Perl value behave
differently in different "contexts" (if a "wrong" conversion was
cached, then preferred to the *present* "exact" value). Yes, all the
contexts are scalar above, in fact there are at least 4 flavors of
scalar context (bool, IV, NV, PV), they are supposed to be
transparent, but are not due to above bugs/features.
Another topic is that some operations give "expected" results when
performed on "small" numbers (such as % or |), when some other
operations allow arbitrary FP numbers as arguments. Even if we forget
that this situation is just plain unacceptable, it remains undocumented.
> I'm sure you'd like infinite precision arithmetic. That's remarkably
> expensive, and it's not what Perl normally does.
Making Perl arithmetic "sane" would not lead to any catastrophic
slowdown, I would expect 2-3% slowdown on the operations which are
currently "broken" (and no slowdown otherwise). A custom
atoi_or_atod() may be needed (so that a wrong SvIVX would not be
cached). Here "sane" means "precision of the result is as bad as one
can expect from double arithmetic, but not worse".
> Remember: computers don't do mathematics, and barely manage arithmetic
> for very limited forms. The fault, by dear Samuel, lies not in Perl,
> but in your computers.
Even if some computers run OSes designed for hardware of 1971 ;-),
this does not alleviate Perl's faults. Perl could *easily* try
harder.
Ilya
------------------------------
Date: Sun, 3 Jan 1999 13:27:14 +0100
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: Bug in Modulo Operator?
Message-Id: <76no3n$qm01@news-sol.swissonline.ch>
Tom Christiansen schrieb in Nachricht
<76n0d0$pd4$1@csnews.cs.colorado.edu>...
>
>In comp.lang.perl.misc,
> "Samuel Kilchenmann" <skilchen@swissonline.ch> writes:
>:If this is "normal" Perl behavior: where can i find a
>:description/specification of the differences in the precision limits
>:between the modulo operator and "normal" arithmetic operations?
>
>So long as you restrict yourself to integers whose abosulute
>values are no greater than 2**31, you shouldn't have any surprises.
>
Thanks for all the replies i've got via news and/or email.
I simply ignored the fact, that % does some kind of integer arithmetics
(which is a little bit strange, given the fact, that all(?) other
arithmetic operations use floating point numbers).
The new little surprise is that % seems to give correct results for
absolute values no greater than 2**32-1 (as long as "no integer;").
Is the % operator the only place, where Perl uses integer arithmetic
(unless "use integer;")?
> OS/2: Yesterday's software tomorrow
s!OS/2!Un*x!
--
Samuel Kilchenmann
skilchen@swissonline.ch
------------------------------
Date: 3 Jan 1999 12:56:17 GMT
From: dformosa@zeta.org.au (David Formosa)
Subject: Re: Bug in Modulo Operator?
Message-Id: <slrn78uq7i.56d.dformosa@godzilla.zeta.org.au>
In article <76no3n$qm01@news-sol.swissonline.ch>, Samuel Kilchenmann wrote:
[...]
>Is the % operator the only place, where Perl uses integer arithmetic
>(unless "use integer;")?
The bitwise boolean operators ~ | ^ >> << do this as well. The range
operator .. dose this trick as well, the repeat operator 'x' will use
ints. Of cause int uses integer arithmetic as dose array accessing.
--
Please excuse my spelling as I suffer from agraphia. See
http://www.zeta.org.au/~dformosa/Spelling.html to find out more.
How to win arguments on usenet http://www.zeta.org.au/~dformosa/usenet.html
------------------------------
Date: 3 Jan 1999 04:36:52 -0600
From: tye@metronet.com (Tye McQueen)
Subject: Re: Converting globs to regexes (was: wildcard)
Message-Id: <76nh84$73u@fohnix.metronet.com>
) Tom Christiansen <tchrist@mox.perl.com> writes:
) > From PCB, chapter 6:
) > sub glob2pat {
[10 lines]
Russ Allbery <rra@stanford.edu> writes:
) I wrote this for the MJ2 project a while back, and although it isn't very
) well tested, I keep meaning to wrap a module around it. This has the
) advantage over your solution that it correctly handles {..,..} csh-style
) expressions, handles [^]*] correctly, and handles escapes.
)
) # WARNING: Untested code.
Try File::KGlob and Fil::KGlob2RE which were written when I was
using an old version of ksh that didn't support ?(...), @(...),
etc. and was compiled to support csh-style {,} stuff so these
two modules really implement csh-style globs rather than modern
ksh-style globs for the most part.
Expect a new release soon.
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: Sun, 03 Jan 1999 10:33:18 GMT
From: bady@primenet.com (Mark Badolato)
Subject: Re: Crypt()
Message-Id: <76nh5k$rre$1@nnrp03.primenet.com>
One thing to keep in mind...
The example given will only work on something that was encrypted with the salt
"aa". If you are using "aa" as a hardcoded salt, then that will be fine.
If not, you will need to accomodate for that. Since the encrypted string's
first two characters are the salt (if you are always using crypt($string,aa)
then look at your encryption file, you'll see that all strings start with
"aa"), use:
$salt = substr($real_pass, 0, 2);
$cypted_pass=crypt($INPUT{password}, $salt);
unless ($crypted_pass eq $real_pass) {
do something
}
Now what happens is, $crypted_pass is encoded the exact same way as
$real_pass, and the two strings may be compared.
--Mark
Previously, "Webmaster" <webmaster@somewhere.com> wrote:
>Thanks. This is what I was looking for.
>
>I have (or will have) a file of users:crypted_passwords. I wanted a way to
>compare an entered password against the file. This way looks like it will
>work great for what I have in mind.
>
>Groovy94 <groovy94@aol.com> wrote in message
>news:19990101125449.11156.00005107@ng100.aol.com...
>>The way I have always checked a submitted password against the already
>crypted
>>one is to crypt the input one and then do an "unless" statement. Example:
>>
>>$cypted_pass=crypt($INPUT{password}, aa);
>>
>>unless ($crypted_pass eq $real_pass) {
>> do something
>>}
>>Regards,
>>Gil Hildebrand, Jr.
>>Dynamic Scripts
>>
>>Email: groovy94@aol.com
>>ICQ UIN: 16678754
>
>
------------------------------
Date: Sun, 3 Jan 1999 10:31:52 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: EXPERIENCED IN PERL ?
Message-Id: <ebohlmanF4zBx5.L4B@netcom.com>
Peter L. Berghold <peter@berghold.net> wrote:
: GSX wrote:
: > I'm presently writing a Perl Coffee Maker. I've got the code to brew a
: > great cup of Hazelnut...but I'm having a problem with the code for
: > decaf.
: >
: > Will this make me ineligible for the job?
: >
: ACH! FOOOEY! No hazelnut. French Roast at double strength dammit! And all
: the caffeine!
Although it's easy to go "OOverboard" and come up with a design that
includes an excessive number of abstract base classes that seem to exist
purely for the sake of existing, this is a case where starting with a
little abstraction up front would result in a more useful product. But
beware of the MI urge; while it may sound superficially appealing to have
hazelnutCoffeeMaker inherit from both dripBrewer and flavoredBeans, a
usage or containment relationship would result in a cleaner design and,
not coincidentally, better model a Real World coffeemaker; my Mr. Coffee
*contains* the ground coffee and transforms it; it never *becomes* the
coffee.
------------------------------
Date: Sun, 3 Jan 1999 10:54:05 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Formatting Dates (Searching for date + 30)
Message-Id: <ebohlmanF4zCy5.M5s@netcom.com>
webmaster@entrepreneur-online.com wrote:
: Scenario: Using the code below, I pieced together a date reminder script that
: supposed to allow a visitor to enter a date and store it into a flat file
: database. The third field is the $dateStamp and the line in the db looks like
: this:
: |1|19990101|Jan. 1, 1999|New Year's Day|
The testable form of the date is in your second field...
: Each time the script loads, it is required to SEARCH the date.txt and see if
: any particular date is within future 30 days of the current date and PRINT
: that date on the resulting html in the form of a checkbox.
: Problem: The script has/will print to screen dates which are from 1998 but not
: from 1999. Where did I make the error and/or where can I locate information on
: formatting dates?
: Code:
: if ($dateStamp %10000 <200)
: { $startDate = $dateStamp -8500;
: }
: if ($dateStamp %10000 >200)
: { $endDate = $dateStamp +8800;
: }
: open (Event,"<$event") || &endIt;
: while ($LINE = <Event>)
: { @terms = split(/\|/,$LINE);
: if ($startDate <= $terms[2] && $endDate >=$terms[2])
But you're making your comparison on your third field. Unless you tell
perl otherwise (and you didn't), Perl arrays are zero-based.
: { print "<LI> <INPUT TYPE=CHECKBOX NAME=\"$terms[1]\"><INPUT TYPE=hidden
: NAME=\"$terms[2]\">";
: print "$terms[3] -- $terms[4]";
All your other field indices are off by one. $terms[4] is undefined.
: }
: }
: close (Event);
------------------------------
Date: Sun, 03 Jan 1999 12:50:32 GMT
From: bady@primenet.com (Mark Badolato)
Subject: Is interpolation/parsing in s/// possible?
Message-Id: <76np74$s3i$1@nnrp02.primenet.com>
This may be a dumb question, but its 5:30am and I've pulled an all-nighter =)
I'm arguing with someone that this cannot be done, he insists it can. But his
insistance is based on the famous "I've seen it but I don't remember where
(a-la "I know you can hide HTML source code" on c.i.w.a.h.).
So, I've been trying to do this as an exercise and have concluded that I can't
(or that im just too tired/stupid to see it right in front of me).
First, I've been trying different ways for the last hour, and I have consulted
The Camel, The Llama, and The Wise Owl. Basically I have confirmed that this
cannot be done (The Wise Owl, on page 246, comes right out and says so, within
the confines of a string), but as I am so damn tired, I thought I would ask as
a verification.
Here goes:
Is it possible to interpolate variables in a regex substitution, but use the
variable contents as the regex for substitution instead of as a literal?
For example:
$name = "MARK";
$regex = '\u\L$1';
$name =~ s/(.*)/$regex/;
Obviously, the above will cause $name to now have a value of "\u\L$1".
But what our argument is about is parsing $regex instead of literally
replacing, so that $name would contain "Mark".
Is there a way to do that? If so it currently escapes me, so how?
*yawn*
Going to bed. Looking forward to any follow-ups, when I wake. =)
Thanks,
--Mark
------------------------------
Date: 3 Jan 1999 14:43:22 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Is interpolation/parsing in s/// possible?
Message-Id: <76nvma$os$1@gellyfish.btinternet.com>
On Sun, 03 Jan 1999 12:50:32 GMT Mark Badolato wrote:
>
> Is it possible to interpolate variables in a regex substitution, but use the
> variable contents as the regex for substitution instead of as a literal?
>
> For example:
>
> $name = "MARK";
> $regex = '\u\L$1';
>
> $name =~ s/(.*)/$regex/;
>
> Obviously, the above will cause $name to now have a value of "\u\L$1".
>
> But what our argument is about is parsing $regex instead of literally
> replacing, so that $name would contain "Mark".
>
> Is there a way to do that? If so it currently escapes me, so how?
>
I have tried out a variety of different ways to do this and the most
usccessfull appears to be:
#!/usr/bin/perl
$name = "MARK";
$regex = 'ucfirst(lc($1))';
$name =~ s/(.*)/eval($regex)/e;
print $name,"\n";
Now I was under the impression that the right hand side of the s/ operation
was interpreted in a double-quotish manner and this appears to be the case
as you have seen. However what you are doing requires that there is a
double interpolation - which wont happen you get one level of interpolation
and thats it. Using the eval() with the /e modifier seems (to me anyhow)
to be the only way of doing this.
The perlop manpage has a comprehensive discussion of the interpretaion of
quote like constructs.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 03 Jan 1999 15:30:52 +0100
From: R. A. Larsen <r_larsen@image.dk>
Subject: Re: locating module GDBM_File
Message-Id: <VA.00000095.008588a5@octo>
"Alain Coetmeur" <Alain.Coetmeur@wanadoo.fr> wrote:
> I've found deadly bug on SDBM
> (each() forget 70% of the key I put in)
> and I'm eager to find a *DBM that work...
I have been bitten by the same bug (build 506), but it went away in build 507.
> do you mean I should try GDBM or DB_File
>
> what is DB_File
AFAIR it is Berkeley DB. The January 1999 issue of Dr. Dobb's Journal mentions a (fast)
full-text search program made in perl using DB_File.
Reni
--
Using Virtual Access
http://www.vamail.com
------------------------------
Date: Sun, 03 Jan 1999 09:12:04 -0800
From: Greg Petranek <webmaster@mcomn.com>
Subject: Lockfile in CPAN
Message-Id: <368FA4E4.E71@mcomn.com>
While running in the CPAN shell from MS-DOS(WIN95) a CPAN install
program was inadvertently terminated causing a ".locklfile" to be
written to my .cpan directory. I can no longer access the remote CPAN
shell with the lockfile installed (error message that CPAN process is
still running).
How do you clear the lockfile? (lockfile message => -93775)
------------------------------
Date: 3 Jan 1999 15:04:58 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Newbie - OPEN() gives sh error - why?
Message-Id: <76o0uq$10i$1@gellyfish.btinternet.com>
On Thu, 31 Dec 1998 17:23:38 GMT Philip de Lisle wrote:
This is actually in reply to a personal e-mail on the same subject however
I was unable to mail because of some problem with the posters mail server.
Sorry Philip.
> I have to open a pipe to a program and pass it some parameters which could
> contain spaces so they need to be in quote marks. My code looks like
>
> $Name = "Philip de Lisle";
> $user = "pdelisle";
> $password = "dsfas/wrh431";
> open(UA, "| /usr/sbin/useradd -M -c '$Name' -p $password $user") || die
> "open: $!";
> close(UA);
>
To do this you do not actually need to do the piped open() at all - all
that is required is to run useradd with system() (or the backticks if you
need to capture the output - but useradd doesnt make any significant
output).
There is no need to pass anything to useradd via STDIN.
You would also have a problem with the *single* quotes around $Name which
would prevent its interpolation by Perl and thus the literal '$Name' will
get passed to the shell for interpolation and almost certainly there isnt
one so thus you error. When you have to mix quotes like this it is better
to use the generalized quoting methods (see perlsyn).
The following is how I would achieve this:
#!/usr/bin/perl
$command = "/usr/sbin/useradd -m";
$Name = "Philip de Lisle";
$user = "pdelisle";
$password = "dsfas/wrh431";
$command_line = qq|$command -c "$Name" $user|;
system($command_line);
The generalized quoting appears in the line where '$command_line' is
assigned to. In order to test this on my system I have had to change some
of the parameters to useradd - It is not possible for instance for me to
specify a password like that on the command line - I can only assume that
your version of useradd allows you to do that (and great it would be too
:) I figure that my '-m' is the same as your '-M' .
> When I execute the open() command I get an error from sh saying that there
> is an error on the quote mark. The actual error codes are
>
> sh: unexpected EOF while looking for `''
> sh: -c: line 2: syntax error
>
This error is caused by the undefined '$Name' being attempted by the
Shell.
In order to make a more robust implementation you might want to check the
$? variable as this should contain the return code from the external
command also the return code of system() is the exit code * 256.
You should check out the perlfunc entry for system() for more on this;
> TIA and Happy New Year
>
And to you !
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 03 Jan 1999 12:45:44 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: noop
Message-Id: <3694660f.4131897@news.skynet.be>
David Formosa wrote:
>Sometimes noop is usefull to say "I'm going to code this but not yet."
>when testing stubbly code.
sub dosomething {
# not implemented yet
}
now, "dosomething" is a noop.
Or use plain comments.
# I'm going to code this, but not yet.
Bart.
------------------------------
Date: 3 Jan 1999 13:13:50 GMT
From: dformosa@zeta.org.au (David Formosa)
Subject: Re: noop
Message-Id: <slrn78ur8e.56d.dformosa@godzilla.zeta.org.au>
In article <3694660f.4131897@news.skynet.be>, Bart Lateur wrote:
>David Formosa wrote:
>
>>Sometimes noop is usefull to say "I'm going to code this but not yet."
>>when testing stubbly code.
>
> sub dosomething {
> # not implemented yet
> }
>
>now, "dosomething" is a noop.
Its an easy to type 4 chars sequence. Faster then thinking up a comment to put
in that place.
--
Please excuse my spelling as I suffer from agraphia. See
http://www.zeta.org.au/~dformosa/Spelling.html to find out more.
How to win arguments on usenet http://www.zeta.org.au/~dformosa/usenet.html
------------------------------
Date: 03 Jan 1999 16:00:22 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: noop
Message-Id: <oeebtkgpibt.fsf@alpha.hut.fi>
dformosa@zeta.org.au (David Formosa) writes:
> In article <3694660f.4131897@news.skynet.be>, Bart Lateur wrote:
> >David Formosa wrote:
> >
> >>Sometimes noop is usefull to say "I'm going to code this but not yet."
> >>when testing stubbly code.
> >
> > sub dosomething {
> > # not implemented yet
> > }
> >
> >now, "dosomething" is a noop.
>
> Its an easy to type 4 chars sequence. Faster then thinking up a
> comment to put in that place.
#nop
--
$jhi++; # http://www.iki.fi/jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: Sun, 3 Jan 1999 10:35:30 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Path under windows
Message-Id: <ebohlmanF4zC36.LC3@netcom.com>
Ethan H. Poole <ehpoole@ingress.com> wrote:
: Speaking personally, I tend to prefer to use my own code (and be responsible
: for its maintenance and any future bugs... I hate depending on an external
: module only to have a new version released with a bug that makes it look like
: bad programming on my part <g>). It gives me total revision control (and a
: singular point of responsibility).
The only way to achieve that is to write in assembler. Otherwise you're
still dependent on external things like C runtime libraries.
A professional programmer tests his code with new releases of modules
before using them.
I think you're really suffering from NIH syndrome, but won't admit it.
------------------------------
Date: Sun, 03 Jan 1999 12:47:03 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Problem with read and eof
Message-Id: <369566ae.4291729@news.skynet.be>
TheLaser wrote:
>I'm very new to perl and am having trouble with the read function. I seem
>to be hitting eof too early (only 131 bytes in for a 430 byte file, 155
>bytes in for a 20473 byte file). I'm using read(SOURCE,$in,1); to get the
>file one byte at a time inside a while loop. If if matters I'm running
>perl under win95. Anybody seen this before?
binmode
I bet there's a chr(26) in there somewhere.
Bart.
------------------------------
Date: 3 Jan 1999 12:56:57 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Problem with read and eof
Message-Id: <76npep$ae$1@gellyfish.btinternet.com>
On Sun, 03 Jan 1999 08:15:53 GMT TheLaser wrote:
> I'm very new to perl and am having trouble with the read function. I seem
> to be hitting eof too early (only 131 bytes in for a 430 byte file, 155
> bytes in for a 20473 byte file). I'm using read(SOURCE,$in,1); to get the
> file one byte at a time inside a while loop. If if matters I'm running
> perl under win95. Anybody seen this before?
Have you using 'binmode' on the filehandles - this is necessary for reading
binary files in the Micrsoft world unfortunately.
perldoc -f binmode
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 03 Jan 1999 15:30:57 +0100
From: R. A. Larsen <r_larsen@image.dk>
Subject: Re: Problem with read and eof
Message-Id: <VA.00000096.008599e5@octo>
prjohnsonat@utahlinxdot.com (TheLaser) wrote:
>
> I'm very new to perl and am having trouble with the read function. I seem
> to be hitting eof too early (only 131 bytes in for a 430 byte file, 155
> bytes in for a 20473 byte file). I'm using read(SOURCE,$in,1); to get the
> file one byte at a time inside a while loop. If if matters I'm running
> perl under win95. Anybody seen this before?
^^^^^
Is the file text or binary data? If it is binary then look at the binmode() function.
I hope this helps.
Reni
--
Using Virtual Access
http://www.vamail.com
------------------------------
Date: Sun, 3 Jan 1999 10:58:13 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Reading comma delimited files
Message-Id: <ebohlmanF4zD51.MI6@netcom.com>
Simon Fairall <Simon.Fairall@hpa.com.au> wrote:
: The problem of using :-
: while ($Line = <INFILE>) {
: @FieldList = split (/,/, $line);
: }
: to seperate the fields is that a text field (delimited by "") could
: legally contain a comma.
: I would appreciate some insight from all you Perl guru's and hackers
: on how to solve this problem.
Most of the available insight is codified in perlfaq4, under "How can I
split a [character] delimited string except when inside [character]?
(Comma-separated files)." There are a couple different recipes there.
You might also look into the Text::CSV module available on CPAN.
------------------------------
Date: Sun, 03 Jan 1999 15:30:59 +0100
From: R. A. Larsen <r_larsen@image.dk>
Subject: Re: Reading comma delimited files
Message-Id: <VA.00000097.0085a420@octo>
Simon.Fairall@hpa.com.au (Simon Fairall) wrote:
>
> I was wondering whether anyone had written a script to parse comma
> delimited files (csv format) as from Microsoft Excel (yuk!).
perlfaq4:
How can I split a [character] delimited string except when inside
[character]? (Comma-separated files)
I hope this helps.
Reni
--
Using Virtual Access
http://www.vamail.com
------------------------------
Date: Sun, 3 Jan 1999 14:19:08 +0100
From: "Madenet" <msantull@dimensione.com>
Subject: Server misconfiguration error
Message-Id: <76nqp3$aeu@dante.italia.com>
I wrote a PERL cgi which works without problems on W95 Perl 32.
It doesn't work in BSDI UNIX even if other Perl script work.
Do you know this problem ?
Thanks
------------------------------
Date: 3 Jan 1999 14:11:18 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Server misconfiguration error
Message-Id: <76ntq6$hp$1@gellyfish.btinternet.com>
On Sun, 3 Jan 1999 14:19:08 +0100 Madenet wrote:
> I wrote a PERL cgi which works without problems on W95 Perl 32.
>
> It doesn't work in BSDI UNIX even if other Perl script work.
>
> Do you know this problem ?
>
I would refer you to Uri Guttman's tirade against this sort of post a day
or two ago.
The only answers are going to be at best sarcastic and at worst of the
most incendiary type.
How do we know what your problem is without the merest snippet of code or
an inkling of an error message. Your subject line moreover is misleading
and will only cause your post to be ignored as off-topic by some.
I think however that you might read the perlport manpage that discusses the
various cross platform portability issues for Perl programs. Failing an
answer from there you might try posting the error message you get and the
code that gave rise to it so we might be able to help further.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 03 Jan 1999 04:26:11 GMT
From: imchat@ionet.net
Subject: uppercase
Message-Id: <368eeafd.122081513@news.ionet.net>
For some reason this bit of code is ignoring all files that start with
an uppercase letter. Any reason why its doing that? The code works
great except for the uppercase filenames.
opendir (COP, "$datadir") || die $!;
@filenames = grep(/\.gif/,readdir(COP));
closedir (COP);
foreach $file (@filenames)
{
copy("$datadir/$file", "C:/1/$file")||die "Can't copy file$!";
}
It should be just matching the file extension rather than
looking at the full filename.
------------------------------
Date: Sun, 3 Jan 1999 10:47:55 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: uppercase
Message-Id: <ebohlmanF4zCnv.Lur@netcom.com>
imchat@ionet.net wrote:
: For some reason this bit of code is ignoring all files that start with
: an uppercase letter. Any reason why its doing that? The code works
: great except for the uppercase filenames.
: opendir (COP, "$datadir") || die $!;
: @filenames = grep(/\.gif/,readdir(COP));
1) Your regex is case-sensitive, so it won't match .GIF, .gIf, etc.
2) Your regex isn't anchored to the end of the string, so it will match
my.gift.recipients, etc.
A trip to perlre and perlop will show you that you can correct these
deficiencies as follows:
@filenames = grep (/\.gif$/i,readdir(COP));
: closedir (COP);
: foreach $file (@filenames)
: {
: copy("$datadir/$file", "C:/1/$file")||die "Can't copy file$!";
: }
: It should be just matching the file extension rather than
: looking at the full filename.
3) Your overall program structure does extra work. You read a list of
filenames (through a filter) one at a time into a "holding tank" and then
subsequently read through the holding tank a line at a time. You could
just as well have written:
opendir (COP, "$datadir") || die $!;
foreach my $file (readdir(COP)) {
next unless $file =~ /\.gif$/i;
copy("$datadir/$file", "C:/1/$file")||die "Can't copy file$!";
}
closedir(COP);
4) You probably want to use warn rather than die if your copy fails, and
you should also get the name of the file into the message string so you
know which file it failed on.
------------------------------
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 4536
**************************************