[8922] in Perl-Users-Digest
Perl-Users Digest, Issue: 2539 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 8 09:17:43 1998
Date: Fri, 8 May 98 06:01:01 -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 Fri, 8 May 1998 Volume: 8 Number: 2539
Today's topics:
Re: Anagram algorithm anyone. <tchrist@mox.perl.com>
Re: CPAN & Module gripes (was Re: Ever Wonder...?) (Chris Nandor)
Re: CPAN Suggestions (conciliatory) (Dr AJ Clune)
Re: CPAN Suggestions (conciliatory) (Dr AJ Clune)
Re: Ever Wonder Why Not Everyone Uses Modules? <fearless@io.com>
Re: Ever Wonder Why Not Everyone Uses Modules? (Chris Nandor)
Re: Ever Wonder Why Not Everyone Uses Modules? (Chris Nandor)
Re: Ever Wonder Why Not Everyone Uses Modules? (Chris Nandor)
Re: Ever Wonder Why Not Everyone Uses Modules? (Chris Nandor)
Re: Graphing databases, need info <perlguy@inlink.com>
Indexing directory's on server <twan.jc.jansen@tip.nl>
Re: Newbie: changing $/ value <ebohlman@netcom.com>
passing variables to external scripts/executables ? scott.seaton@aus.sun.com
Perl 5.004_04 bug ()
Perl NT IIS PWD <l.nap@thekitchen.nl>
Re: perl scripts dealing with /etc/passwd <hrowe@erinet.com>
Re: RC1867 upload on NT problem <ebohlman@netcom.com>
Re: RC1867 upload on NT problem <perlguy@inlink.com>
Re: removing nested parentheses <jhoglund@mirage.skypoint.net>
Re: returning a list from a recursive function zbrown@lynx.neu.edu
Re: Win95 Perl scripts DONT WORK on UNIX (Paul Rolfe)
Re: Windows 95 Problem <ebohlman@netcom.com>
Writing to Text fields <lawrence@wantree.com.au>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 8 May 1998 12:03:13 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Anagram algorithm anyone.
Message-Id: <6iusa1$gcr$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Jerry Pank <jerryp.usenet@connected.demon.co.uk> writes:
:Below is my hopeless attempt at an anagram algorithm.
:Almost works for 4 letters but (obviously) miserable with n letters.
:
:Does anyone have a ``standard'' algorithm for calculating anagrams?
#include <stdio.h>
#include <ctype.h>
#include <sysexits.h>
#include <signal.h>
#include <setjmp.h>
#include <malloc.h>
#define INPUT "/usr/dict/words"
#define COUNT ('z' - 'a' + 2)
#define EOW ('z' - 'a' + 1)
struct dict_level {
struct dict_level *ltr[COUNT];
} Table;
struct letterpad {
int count;
char ltr[COUNT];
};
typedef long L32;
jmp_buf Prompt_Env;
char Line[100];
char Word[100];
char *Letter;
L32 Word_Count = 0;
L32 Allocated = 0;
L32 Slots;
int Debug = 0;
int Phrase_Mode;
int Max_Idx;
char *Program;
extern int isatty();
int from_a_tty, to_a_tty;
int fetch();
void interrupt();
void usage(), store(), dump(), anagram();
int
main(ac, av)
int ac;
char **av;
{
FILE *fp;
char *input;
from_a_tty = isatty(0);
to_a_tty = isatty(1);
Program = *av;
if (ac > 4)
usage();
if (ac == 3 || ac == 2) {
if (strcmp(av[1], "-p"))
usage();
ac--; av++;
Phrase_Mode = 1;
}
Max_Idx = Phrase_Mode ? COUNT : EOW;
input = ac == 2 ? av[1] : INPUT;
if (!(fp = fopen(input, "r"))) {
perror(input);
exit(EX_NOINPUT);
}
setlinebuf(stdout);
while ( fgets(Line, sizeof(Line), fp) ) {
Word_Count++;
if (Debug) printf("storing %s", Line);
store(Line);
}
*(Letter = Word) = '\0';
{
L32 slotmax = Allocated * 26;
dump(&Table);
fprintf(stderr, "%ld Words, %ld levels\n", Word_Count, Allocated);
fprintf(stderr, "%ld/%ld pointers used (%4.1f%%)\n",
Slots, slotmax,
100 * ((double)Slots)/((double)slotmax));
}
signal(SIGINT, interrupt);
while (1) {
setjmp(Prompt_Env);
if (from_a_tty)
printf("> ");
if (!gets(Line))
break;
anagram(Line);
}
exit(EX_OK);
/*NOTREACHED*/
}
void
store (s)
char *s;
{
struct dict_level *dp = &Table;
char a,*cp;
for (cp = s; *cp && *cp != '\n'; cp++) {
if (isupper(*cp))
*cp = tolower(*cp);
if (*cp < 'a' || *cp > 'z')
return;
a = *cp - 'a';
if (!dp->ltr[a]) {
if (!(dp->ltr[a] = (struct dict_level *)
calloc(1, sizeof(struct dict_level))))
{
perror("calloc");
exit(EX_OSERR);
}
Allocated++;
}
dp = dp->ltr[a];
}
dp->ltr[EOW] = (struct dict_level *) -1;
}
void
dump(dp)
struct dict_level *dp;
{
char digit;
if (!dp) {
fprintf(stderr, "can't get here!!!\n");
return;
}
for (digit = 0; digit < COUNT; digit++) {
if (dp->ltr[digit]) {
Slots++;
if (digit == EOW) {
if (Debug) printf("Word! %s\n", Word);
*--Letter = '\0';
return;
}
*Letter = digit + 'a';
*++Letter = '\0';
dump(dp->ltr[digit]);
}
}
*--Letter = '\0';
}
void
anagram(s)
char *s;
{
struct letterpad master;
int i;
char *cp;
for (i = 0; i < 26; i++)
master.ltr[i] = 0;
master.count = 0;
if (Phrase_Mode) master.ltr[EOW] = 1;
for (cp = s; *cp; cp++) {
if (isupper(*cp))
*cp = tolower(*cp);
if (*cp < 'a' || *cp > 'z')
continue;
master.count++;
master.ltr[*cp - 'a']++;
}
*(Letter = Word) = '\0';
fetch(&Table, &master);
}
int
fetch (tp, pp)
struct dict_level *tp;
struct letterpad *pp;
{
int i;
if (pp->count == 0) {
if (tp->ltr[EOW] && strcmp(Line,Word)) {
printf("%s: %s\n", Line, Word);
if (ferror(stdout)) {
perror("can't write to stdout");
exit(EX_IOERR);
}
return 1;
}
return 0;
}
for (i = 0; i < Max_Idx; i++) {
if (pp->ltr[i] && tp->ltr[i]) {
if (Phrase_Mode && i == EOW) {
*Letter++ = ' ';
fetch(&Table, pp);
} else {
*Letter++ = i + 'a';
pp->ltr[i]--;
pp->count--;
fetch(tp->ltr[i], pp);
pp->ltr[i]++;
pp->count++;
}
*--Letter = '\0';
}
}
return 0;
}
void
usage ()
{
fprintf(stderr, "usage: %s [-p] [dictionary]\n", Program);
exit(EX_USAGE);
/*NOTREACHED*/;
}
void
interrupt() {
printf("\n");
longjmp(Prompt_Env,0);
/*NOTREACHED*/;
}
#ifdef NO_SETLINEBUF
int
setlinebuf (fp)
FILE *fp;
{
(void) setvbuf(fp, NULL, _IOLBF, 0);
return(0);
}
#endif
--
The debate rages on: Is PL/I Bactrian or Dromedary?
------------------------------
Date: Fri, 08 May 1998 10:51:45 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: CPAN & Module gripes (was Re: Ever Wonder...?)
Message-Id: <pudge-0805980649530001@192.168.0.3>
In article <35537a68.1804689077@192.0.0.10>, cpierce1@ford.com (Clinton
Pierce) wrote:
# I am quite competant to run a Makefile. So are many of the
# other responders on this thread. The CPAN gripes I have, and
# that others seem to agree on could be solved completely with a
# 1. dependencies list, available from CPAN, that is accurate,
# greppable and (preferably) does not rely on the module author
# keeping an accurate description file and (while we're wishing) 2. a
# keyword search.
There IS a keyword search, as Randal and I went to significant lengths to
show yesterday.
perl -MCPAN -e shell
cpan> wq MIME::Parse
Or go to Yahoo! and type "CPAN search".
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
MacPerl: Power and Ease (ISBN 1881957322), http://www.ptf.com/macperl/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: 8 May 1998 10:19:58 GMT
From: ajc22@york.ac.uk (Dr AJ Clune)
Subject: Re: CPAN Suggestions (conciliatory)
Message-Id: <6ium8e$rev$1@pump1.york.ac.uk>
Ok, I'll jump into this bed of flames. I've always installed modules
(and I've installed quite a few) via ftp and
$ perl Makefile.PL; make; make install;
The only real problems I've had with this have been broken things in my
installation, not problems with CPAN.
However: the serach engine for CPAN is rather hidden - I hadn't actually
noticed it until it came up on this thread. It is mentioned in CPAN.html
but I, like many others I guess, tend to just jump down the page to
the module listing. If you want to tell me I should read all the page,
then I'll accept that you're right :-), but why not just move the search
link to the very top of CPAN.html.
That would help straight away.
CPAN.pm - I'm not convinced that it's that easy for a new perl user (note
I'm _not_ saying "clueless nubie here, just someone new to perl) to find.
My version of the Camel book doesn't mention it.
$ perldoc perldelta
will, but that's not the most obvious of things for a new user either.
Prehaps this should be mentioned a bit more promently in CPAN.html as
well, with a pointer to a FAQ about it's use?
Mike Heins (mikeh@minivend.com) wrote:
: Clinton Pierce <cpierce1@cp500.fsic.ford.com> wrote:
: > Idea #1:
: > I'll open with something simple: can the modules be extracted/parsed/
: > folded/spindled in some automagic way to extract dependency information?
: > Possibly looking for things like:
: Not really -- it would immediately run into problems with things like:
: [eval example]
Surely it's possible to write a program that would detect things like
that. I realise it wouldn't be trivial, but wouldn't it be possible to
say something like
"Modules need by MySuperMod.pm (it may be possible that the module needs
less than this list, please see <A HREF="MySuperMod_docs.html"> the docs
</a>."
: Why don't you mirror CPAN to a local directory, then use CPAN and a
: file:// URL? It isn't all that much on a daily basis. It works fine with
: CPAN.pm. If you can't get past your firewall, use an offsite PC and a CDR.
Now this is getting a bit excessive. I don't really want to have to go to
the effort (and file space requirements) of mirroring something, just to
search it. It's also not very pratical via a dial-up line.
: I posted a request for people to show me something which does something
: similar, commercial or free, and does it better than CPAN. I haven't seen
: any pointers to anything yet.
No, and I don't think you'll get them, but (as has been said before) that
doesn't mean we can't discuss ways of making things better.
Arthur
-------------------------------------------------------------------
| Arthur Clune, Network Control Group, Department of Mathematics, |
| University of York. Tel/Fax 01904 433097 |
| http://biber.york.ac.uk/~arthur
-------------------------------------------------------------------
------------------------------
Date: 8 May 1998 11:15:00 GMT
From: ajc22@york.ac.uk (Dr AJ Clune)
Subject: Re: CPAN Suggestions (conciliatory)
Message-Id: <6iupfk$b6j$1@pump1.york.ac.uk>
I follow-up to my own message...
Dr AJ Clune (ajc22@york.ac.uk) wrote:
: [re: CPAN.pm]
: Prehaps this should be mentioned a bit more promently in CPAN.html as
: well, with a pointer to a FAQ about it's use?
Ok, my web connection wasn't working earlier, so I've now had another look
at CPAN, and think I was wrong. CPAN.pm is mentioned in a sufficently
prominent place, and the README file for it is a model of what a readme
file should be like.
I hold by my comments about the search engines though. There are good
reasons why most sites have the search engine promently displayed.
Arthur
-------------------------------------------------------------------
| Arthur Clune, Network Control Group, Department of Mathematics, |
| University of York. Tel/Fax 01904 433097 |
| http://biber.york.ac.uk/~arthur
-------------------------------------------------------------------
------------------------------
Date: Thu, 7 May 1998 15:33:47 -0500
From: Creede Lambard <fearless@io.com>
Subject: Re: Ever Wonder Why Not Everyone Uses Modules?
Message-Id: <Pine.BSI.3.96.980507151936.6915A-100000@pentagon.io.com>
BAD example, Tom. BAD example. Why should I deprive myself of the pleasure
of poetry simply because I can't read the original, when I can gain so
much from it? Why would I want to cut myself off from the adventures of El
Cid? Or the allegories of Dante? Or the comedies of Moliere or the
tragedy of Faust? Deny myself Homer, one of the underpinnings of
our culture? And whether you know it or not, the Bible consists in large
measure of poetry (which, depending on your viewpoint, may be a bad
example on my part -- but regardless of what you think of it, it is
another underpinning of our cultore).
And what of going the other direction? Would you deny those who cannot or
do not choose to read English the opportunity to experience Shakespeare,
Milton, Whitman, Angelou or Silverstein? I agree that, given the choice,
one gets more of the author's intention by reading in the original, but in
the absence of that choice, I would rather be able to read poetry in
translation than not be able to read it at all.
I'm not entirely sure how this applies to Perl, except to say that I work
on Linux, Mac, and yes, the dreaded Platform That Must Not Be Named
otherwise known as DOS/Windows, and as long as I have the opportunity to
use Perl, I would rather program with it than without it.
.:::::::::::::::::::::::::::::::::::::::::::::::::::::::.
:: Creede Lambard :: Put something silly in the world ::
:: fearless@io.com :: that ain't been there before! ::
:: published poet :: - Shel Silverstein ::
\:::::::::::::::::::::::::::::::::::::::::::::::::::::::/
On 7 May 1998, Tom Christiansen wrote:
> Who wants to read poetry translated? To what purpose? To translate
> poetry carries with it the inevitable doom that its allusions and
> metaphors, its delicate aesthetics and pleasing symmetry, that shall be
> thus destroyed, reduced to a palimpsest--nay, a caricature--of true art.
>
> --tom
> --
> Tom Christiansen tchrist@jhereg.perl.com
>
>
> "I think I'll side with the pissheads on this one." --Larry Wall
>
>
------------------------------
Date: Fri, 08 May 1998 10:56:06 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Ever Wonder Why Not Everyone Uses Modules?
Message-Id: <pudge-0805980654140001@192.168.0.3>
In article <6iu68l$6a5$1@news.NERO.NET>, stanley@skyking.OCE.ORST.EDU
(John Stanley) wrote:
# In article <6itrt4$30o$1@Mercury.mcs.net>, Leslie Mikesell <les@MCS.COM>
# wrote:
# >If you have POP clients you will
# >also almost certainly have a reliable SMTP relay, but there is no
# >handy way to find it without manual configuration.
#
# I have yet to see a POP client that didn't require manual configuration,
# even for those not behind firewalls.
Hm. Just installed Mailsmith the other day. I had not one jot of
configuration to do for it to get my mail. My mail prefs were sucked in
from my IC settings, so I didn't have to do it manually. I did change
some things manually, but I didn't have to in order for it to get my mail.
But then again, Macs are extra cool.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
MacPerl: Power and Ease (ISBN 1881957322), http://www.ptf.com/macperl/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Fri, 08 May 1998 11:00:17 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Ever Wonder Why Not Everyone Uses Modules?
Message-Id: <pudge-0805980658250001@192.168.0.3>
In article <6it870$2o6@fridge.shore.net>, Art Cohen <upsetter@shore.net> wrote:
# Chris Nandor <pudge@pobox.com> wrote:
#
# : * your sysadmin changes the name of the mail server
# : * your sysadmin responsibly lets you know
# : * you notify him what needs to be changed, where, and how, maybe even
making
# a
# : diff for him
#
# You left out
# * He ignores you, or says "I'll get to that this week" and then doesn't.
# These things sometimes happen in real life.
Then your sysadmin sucks. Perl and CPAN and modules are not responsible
for such human deficiencies. As I said, don't shoot your parents and ask
for mercy because you are an orphan; the management assumes no
responsibility.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
MacPerl: Power and Ease (ISBN 1881957322), http://www.ptf.com/macperl/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Fri, 08 May 1998 11:02:40 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Ever Wonder Why Not Everyone Uses Modules?
Message-Id: <pudge-0805980700480001@192.168.0.3>
In article <894597310.838511@thrush.omix.com>, Zenin
<zenin@archive.rhps.org> wrote:
# Think about this; If where were printing files instead of sending
# mail, would you me manually connecting to a remote lpd instead of
# calling lpr? Think hard about this, because this is the *exact*
# same case as with sending mail. The *exact* same case... Your
# application is working at the *wrong* level of the protocal stack,
# it's that simple.
If it works, and it doesn't break anything, and it follows all the
protocol standards, how can it be wrong? Just because you don't like it?
Incroyable. No sense do you make.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
MacPerl: Power and Ease (ISBN 1881957322), http://www.ptf.com/macperl/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Fri, 08 May 1998 11:17:14 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Ever Wonder Why Not Everyone Uses Modules?
Message-Id: <pudge-0805980715220001@192.168.0.3>
In article <Pine.BSI.3.96.980507151936.6915A-100000@pentagon.io.com>,
Creede Lambard <fearless@io.com> wrote:
# And what of going the other direction? Would you deny those who cannot or
# do not choose to read English the opportunity to experience Shakespeare,
Everyone knows you have to read Shakespeare in the original Klingon to
really get its measure.
Hegh. Qong. QongDI' chaq naj. toH, waQlaw' guh'vam!
HeghDaq maQongtaHvIS, tugh nuq wInjalaH,
volchaHmajvo' jubbe'wI'bep wIwoDDI'
'e' wIqelDI', maHeDnIS. Qugh DISIQnIS,
SIQmoHmo' qechvam. Qugh yIN nI'moH 'oH.
One dies. One skeeps. When one sleeps, perhaps one dreams.
Well, this situation seems to be the obstacle!
What we can soon dream of, while sleeping in death,
Having thrown away from our shoulders the cargo of the mortal --
When we consider that, we must retreat. We must endure disasters,
Because this idea makes us endure them.
It lengthens the life of the disasters.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
MacPerl: Power and Ease (ISBN 1881957322), http://www.ptf.com/macperl/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Fri, 8 May 1998 12:08:40 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Graphing databases, need info
Message-Id: <3552F5C8.FB1FE70F@inlink.com>
Ryan,
Go to www.perl.com and click on "Graphics and Imaging". There are links
to items such as the GD module, GIFgraph module, ...
If you have any problems implementing my "database", let me know.
Good luck!,
Brent Michalski
------------------------------
Date: 8 May 1998 10:06:00 GMT
From: "Twan Jansen" <twan.jc.jansen@tip.nl>
Subject: Indexing directory's on server
Message-Id: <01bd6e9e$dc075c80$9f5b12c3@www>
I have a site where in multiple directory's html pages are stored
the pages are deleted, moved and uploaded very often so it is a hell of a
job to make a tabel of contents.
My trouble is that i can't use Frontpage's 98 navigatie webbot because the
file's are uploaded not only by myself but also by others
My question is so: Is there a way that i can get the titles of my Html
pages in the directory and show in a html page with can been seen by
everybody.
I know a little about perl , how to make it work things like that but i
simple I haven't got experience in writing scripts myself.
Frontpage is a nice program but if you want to go a little fearder you come
in trouble.
greetings twan.jc.jansen@tip.nl
------------------------------
Date: Fri, 8 May 1998 11:11:18 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Newbie: changing $/ value
Message-Id: <ebohlmanEsMxqu.oI@netcom.com>
Clay Loveless <clay@crawlspace.com> wrote:
: I'm working on a script that needs multiple line input for one response.
: Right before asking the question to prompt that response, I've put this line
: in the script:
: $/="###";
: .... so that after I've entered my multiple lines, I type "###", hit enter, and
: the script proceeds.
: My problem:
: How to I return to the default value of $/ ? I've tried the following:
One way to handle this is to put the code that requires multi-line
input in a block and localize $/ inside the block:
$single1=<STDIN>;
{local $/="###";
$multi=<STDIN>;
}
$single2=<STDIN>;
------------------------------
Date: Fri, 08 May 1998 11:45:53 GMT
From: scott.seaton@aus.sun.com
Subject: passing variables to external scripts/executables ?
Message-Id: <6iur9h$s1f$1@nnrp1.dejanews.com>
Hi
I'm working on a cgi perl script (using CGI.pm - great module btw). I'm
tryingto pass a large (~15k) variable to another perl script (html2ps.pl), I
thenneed to recover the output (~1.5MB) and forward it as a MIME e-mail
attachment and also pass it back out to a system executable.
I'm trying to
avoid temp files (I'm short of disk - but have RAM to spare). Ihaven't been
able to find a clear description of how to do this either on-lineor in any
of my perl books....
How do I pass variables to external script/executables
? And then recoverstdout for further processing ?
Thanks
Scott
=============================================================================
= ,-_|\ Scott Seaton - Customer Services Systems Consultant
/ \ Sun
Microsystems Australia Pty Ltd E-mail : scott.seaton@aus.sun.com\_,-\_+
828 Pacific Highway Phone : +61 2 9844 5381 v Gordon, N.S.W., 2072,
AUSTRALIA Fax : +61 2 9844 5161
=============================================================================
=
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 8 May 1998 12:22:49 GMT
From: LOGIN@teleda ()
Subject: Perl 5.004_04 bug
Message-Id: <6iutep$spf@news01.aud.alcatel.com>
Keywords: leave_scope
Below is a section of code that produces the following error:
panic: leave_scope inconsistency at /usr/local/bin/add_acctd line 41
panic: leav_scope inconsistency
This error is encountered when using 5.004_04
The previous version 5.003 works fine. The os version is Solaris 2.6
for ( ; $paddr = accept(Client,Server); close Client) {
my ( $port, $iaddr ) = sockaddr_in($paddr) ;
my $name = gethostbyaddr($iaddr, AF_INET) ;
logmsg "connection from $name [",inet_ntoa($iaddr), "] at port $port"
;
#server receives message from client
recv(Client, $line, 50, 0) ;
system ("/bin/pwd") ; #this is line 41 where error occurs
}
Any suggestions on a work around for this bug?
Al Alder
Alcatel Network Systems
------------------------------
Date: Fri, 08 May 1998 14:13:47 +0200
From: Lars Nap <l.nap@thekitchen.nl>
Subject: Perl NT IIS PWD
Message-Id: <3552F6FB.40E7FECE@thekitchen.nl>
Normally when I'm executing a Perl script on a Unix machine (and a
Netscape webserer) the path working directory (PWD) is the same as the
directory of the perl script.
When I'm executing a perl script on NT and IIS the PWD is not the same
as the directory of the perl script.
Does anyone know how to be sure that the PWD is the same as the
directory of the perl script!
Lars Nap (l.nap@thekitchen.nl)
------------------------------
Date: Fri, 8 May 1998 07:28:13 -0400
From: "Harry Rowe" <hrowe@erinet.com>
Subject: Re: perl scripts dealing with /etc/passwd
Message-Id: <6iuqnq$8h@nntp1.erinet.com>
Allan M. Due wrote in message <6it7o8$6c1$0@206.165.146.147>...
>Tom Phoenix wrote in message ...
>
>...Snip...
>
>
>>> if ($ENV{'REQUEST_METHOD'} eq "POST"){
>>>
>>> # Get the input
>>> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
>>
>>Yes, this is the same broken code we've seen dozens of times.
>
>Sorry to be slow, but what is wrong with the above code? I have been
>working on learning Perl over the past few weeks and I have seen code that
>looks like the above all over the place (including an O'Reilly publication
>which shall remain nameless). Could someone fill me in on why this code
is
>broken? Edification is greatly appreciated.
>
>AmD
I'm curious also. In this script I did not use cgi.pm.
I receive POST data from a java on-line-chat applet using:
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$contents{$name} = $value;
}
It works fine. Why would this be broken? I am a mechanical engineer
who is a recreational programmer and not a Perl guru so please
enlighten me.
Regards,
Harry
------------------------------
Date: Fri, 8 May 1998 11:21:21 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: RC1867 upload on NT problem
Message-Id: <ebohlmanEsMy7L.zw@netcom.com>
Martin Schlatter <sla@opencon.ch> wrote:
: I've written a upload cgi sript which reads the number of bytes
: in CONTENT_LENGTH from stdin. This perl cgi runs fine
: on linux but on NT4.0 it starts reading but after a while the
: sysread call blocks and the script never returns. I even can't
: end the perl task with the task-manager! Does anyone know
: about a upload cgi script which also runs on NT?
Please don't take this as a flame, but...
Ask yourself, honestly, how you'd expect anyone to figure out why your
code is misbehaving if they don't know what that code *is*. All you've
given us to go on is that the code contains a call to sysread somewhere.
You haven't told us what context that call occurs in, which is pretty
essential information for anyone trying to debug your code. AFAIK, none
of the people who frequent this group are telepaths.
If the script is short, post the whole thing. If it's long, isolate the
section where there are problems and post that section.
------------------------------
Date: Fri, 8 May 1998 11:36:27 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: RC1867 upload on NT problem
Message-Id: <3552EE3B.E23E3458@inlink.com>
Have you used binmode(STDOUT)?
Also, if you are using Internet Exploder 3.0x to upload, and you have a
<SELECT><OPTION>.........</SELECT> statement in your code, you will have
problems because IE sends an extra & to the CGI program and really
screws it up.
I put in a $select_var=~s/\s{1,}\&//g; and solved the problem.
Last, to kill off the Perl process, have you tried using the kill.exe
file located in the Resource Kit? It usually works. If it doesn't, or
you can't kill it, you need to shut down the web server, then kill the
processes, then restart the web server.
HTH,
Brent
------------------------------
Date: 8 May 1998 12:36:55 GMT
From: Jamie Hoglund <jhoglund@mirage.skypoint.net>
Subject: Re: removing nested parentheses
Message-Id: <6iuu97$8ih$1@shadow.skypoint.net>
Doug E Fresh <dhaber@seas.upenn.edu> wrote:
: Is it possible to create a search string that will find the most nested
: parentheses in a string or do I have to use index, substr etc. etc.
: i.e.
: $string = "2*(3+(4+5))"
: $string =~ s/somthing/&process($1)/e
: # where $1 = "4+5"
: thanks a bunch,
: Doug
I have files that contain things like: &VAR{&FUN{Data}};
Each &NAME{....}; does a particular thing, I wound up using a recursive
function to goto the inside "function" expand it, and move outward. Here's
a couple snips of it:
sub lookup_function($func,$param){ #{{{
.....
$function = shift;
$param = shift;
.....
$param =~ s/\&([A-Z]+)\{(.*)\}/&lookup_function($1,$2)/ge;
.....
}
Please, don't run this w/out making sure there are no "unlink" statements
in it. :-) The whole file is a couple hundred lines long and I'm only
posting the part that you might be able to use.
I'm guessing you might be able to use some sort of counter or other
mechanism to determine if you're in the innermost loop, possibly pushing
the parameter on to a list? thats something I wouldn't know off hand. But
the above seems to work for executing things from the innermost to the
outermost.
Each time &lookup_function is called, it looks for anything from { to }
passing the contents to itself, where it does it again, until there are no
{'s remaining.
I'm thinking you could so something like change:
$param =~ s/\&([A-Z]+)\{(.*)\}/&lookup_function($1,$2)/ge;
to:
$param =~ s/(\([^\)]+)/&lookup_function($1)/ge;
For sure you need a counter to make sure you don't recursively curse
yourself into oblivion. And I didn't test the *modified* regular
expression, the idea was to convey using recursion to get to the innermost
bracket. May not be the best way, but *something like it* worked for my
application, which had a similiar problem.
Jamie
------------------------------
Date: 8 May 1998 11:43:37 GMT
From: zbrown@lynx.neu.edu
Subject: Re: returning a list from a recursive function
Message-Id: <6iur59$rfc$1@isn.dac.neu.edu>
In article <3552A372.19409DB1@coos.dartmouth.edu>,
Ronald J Kimball <rjk@coos.dartmouth.edu> wrote:
>
>How about this:
It works!
I *never* would have come up with that. Thanks!
Someone should translate the Linux kernel source into Perl. It would be just
as good, and only 21K.
Zack
>--
> _ / ' _ / - aka - rjk@coos.dartmouth.edu
>( /)//)//)(//)/( Ronald J. Kimball chipmunk@m-net.arbornet.org
> / http://www.ziplink.net/~rjk/
> "It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Fri, 08 May 1998 10:15:26 GMT
From: prolfe@southwest.com.au (Paul Rolfe)
Subject: Re: Win95 Perl scripts DONT WORK on UNIX
Message-Id: <3552dadb.25057398@news.southwest.com.au>
On Wed, 6 May 1998 18:01:31 -0700, "edepot" <phlin@ix.netcom.com>
wrote:
>
>Hello. I found out that perl scripts written to run
>on Windows 95 Perl DOES NOT WORK
>on unix Perl.
>
>The reason is that Windows (or DOS) puts a
>character "^M" after a line, and UNIX perl
>does NOT understand this character.
>
>The only way to fix it is if you have a utility
>to STRIP the "^M" characters on the scripts from unix
>side after you have ftp'ed them from your
>win95 computer. You can
>see the characters by editing the file using
>vi editor from the UNIX side.
>
>My question is, HOW DO YOU STRIP THE
>"^M" character? Is there a perl script that
>does this? Is there a /usr/bin program that
>I can use to achieve this on many files?
Well, on Linux, you can:
tr -d '\r' < input_file > output_file
Hope this helps.
------------------------------
Date: Fri, 8 May 1998 10:55:06 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Windows 95 Problem
Message-Id: <ebohlmanEsMwzu.n1y@netcom.com>
Bob Rasmussen <bobras@erols.com> wrote:
: I just did a backup from my Windows 95 machine at work and
: a restore on my Windows 95 machine at home. When trying
: to execute a simple
: C:\PERL5>PERL -V I receive
: "Program will not run in DOS mode" Can anyone suggest why
: I have a problem with the home system, but, not the work system?
Most likely the "DOS prompt" on your home machine has the "use MS-DOS
mode" option set, which makes the Win32 API invisible to programs run
under it (it's a compatibility mode for DOS applications that rely on
undocumented features that aren't supported in the standard Win95 console
interface). If you type "exit" at your DOS prompt, does Win95 partially
reload? If so, you've got "use MS-DOS mode" set. The solution is to
either change the properties for your "DOS prompt" shortcut, or create
another shortcut without "use MS-DOS mode."
------------------------------
Date: Fri, 8 May 1998 20:39:02 +0800
From: "Shane" <lawrence@wantree.com.au>
Subject: Writing to Text fields
Message-Id: <6iuuaf$qo5$1@news.wantree.com.au>
Is there a way to loop a perl script so it continuously does something until
something happens and is there a way to get your script to write something
into a text area?
Shane Lawrence
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 2539
**************************************