[6893] in Perl-Users-Digest
Perl-Users Digest, Issue: 517 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 22 22:07:18 1997
Date: Thu, 22 May 97 19:00:37 -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 Thu, 22 May 1997 Volume: 8 Number: 517
Today's topics:
Re: "email me when the URL changes" script? (Tung-chiang Yang)
Re: 2-way communication with unix command <merlyn@stonehenge.com>
Re: 2-way communication with unix command (Terrence M. Brannon)
[Win32] @INC, -I, Perl5Lib in Perl Win32 serstad@acc.jc.edu
Re: array of arrays (Bill)
Re: calculation (Tim Smith)
Can't get $! to print ERRORLEVEL value <pierre_porter@compuware.com>
Can't locate Term/ReadLine/Gnu.pm in @INC <kshaw@plight.lbin.com>
Catching errors from packages <eusrocky@exu.ericsson.se>
Re: File Locking w/ PERL <merlyn@stonehenge.com>
Re: Getting Week Number (Bob)
Re: Help Needed with Perl Script under OpenVMS (Jonathan Hudson)
How to process logfiles with begin/end brackets? (Craig Schenk)
Re: how to remove carriage returns in form (Bill)
IIS Server Hangs when executing a perl script <rmaillet@inigo.us.dg.com>
Re: Installing a Module in local directory <merlyn@stonehenge.com>
Re: Locking my Log file... (Bill)
Re: Lotus Spreadsheet file parser (Russell Schulz)
Re: Making a pool, but one man = one vote (Craig Berry)
Members Only Section? <spooner@mail.eden.com>
mktemp for perl <cowan@pop.jpl.nasa.gov>
Re: My keys are numbers... <jhi@alpha.hut.fi>
my(), foreach, and perl 5.004 (Richard S. Smith)
Re: Newbie writing to a file question. (Tung-chiang Yang)
Re: Newbie writing to a file question. (Tad McClellan)
Re: NT 4.0 CGI with PERL <djohnson@uu.net>
Re: output-> Content-Length: (Nathan V. Patwardhan)
Re: parsing one line at a time problem. <simonk@telebusiness.co.nz>
Re: Q: setsockopt SOCKET, LEVEL, OPTNAME, OPTVAL <roderick@argon.org>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 22 May 1997 19:31:54 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: "email me when the URL changes" script?
Message-Id: <tcyangEALKx6.HEr@netcom.com>
Pages with server side include counters will change every time you
touch it...... The only way to see if a page changes is checking
its modification time, but I am not sure if lynx or telnet 80 can
do this.
=================================
Simon Fairey (sfairey@metrica.co.uk) wrote:
: Although useful ( especially from an educational point of view ) there
: is a slight problem with the script. Adverts ( which are everywhere
: these days ) do not always come through as the same thing when you look
: at the HTML. I have absolutely no idea what to look for to prevent this
: but I have posted something to comp.infosystems.www.authoring.html to
: see if anyone can point me in the right direction.
: Thanks again for the script tho its still v.useful.
--
Tung-chiang Yang tcyang@netcom.com
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.clever.net/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: 22 May 1997 14:51:22 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: aml@world.std.com (Andrew M. Langmead)
Subject: Re: 2-way communication with unix command
Message-Id: <8cyb972n1h.fsf@gadget.cscaper.com>
>>>>> "Andrew" == Andrew M Langmead <aml@world.std.com> writes:
Andrew> Unfortunately, it assumes you are using perl5. Two or so years ago,
Andrew> when everyone was using perl version 4, [...]
My, how time flies. Perl5.000 was released 2.7 years ago, and was in
usable alpha/beta releases since at least mid 1993. "Everyone was
using perl version 4" hasn't been true for roughly 4 years.
Perl4 is dead, long dead. Long live Perl5 (until Perl6 comes along :-).
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 466 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 22 May 1997 15:37:07 -0700
From: brannon@bufo.usc.edu (Terrence M. Brannon)
Subject: Re: 2-way communication with unix command
Message-Id: <ysizk9kr6smn.fsf@bufo.usc.edu>
Does the functionality of chat2.pl overlap with open2.pl?
--
o============o Sending unsolicited commercial e-mail (UCE) to this address
Legal Notice is indication of your consent to pay me $120/hour for 1 hour
o============o minimum for professional proofreading & technical assessment.
terrence brannon * brannon@rana.usc.edu * http://rana.usc.edu:8376/~brannon
------------------------------
Date: Thu, 22 May 1997 14:51:24 -0600
From: serstad@acc.jc.edu
To: serstad@acc.jc.edu
Subject: [Win32] @INC, -I, Perl5Lib in Perl Win32
Message-Id: <864330304.31433@dejanews.com>
Hi,I'm having some problems with adding paths to the library search
pathfor the purpose of calling modules in Perl for Win32. I have
settledfor a semi-satisfactory workaround, but would be delighted to find
outwhy the following do not work for me.1) -I doesn't work, most likely
because I need a C preprocessor. Isthere any simple and easy way to get
this flag to work with Win32?2) Can you not simply add modules to
directories under the bindirectory if it is your path? This also does
not seem to work.3) Supposedly, Perl5 is supposed to look for the
environment variablePERL5LIB and use that as an override or complement to
the library pathin the registry. Is there any reason why this does not
work in Win32Perl?4) Along those same lines, I can explicitly add the
PERL5LIBenvironment variable to the search with the following: BEGIN
{@INC=($ENV{'PERL5LIB'},@INC);}This solves my problem, but it still means
I have to add this to allof my scripts. I have no idea how BEGIN affects
performance. Not themost optimal solution, but at least it works.I know
the library path is stored in a key in the registry, and theinstall batch
file works fine. However, for a number of reasons, Iwould like to run
perl across a network and not add things to theregistry of the machine
that I am running it on. Also, I may notalways be running perl from the
same drive letter, depending on whatdrive letters are available for
mapping. Thus, I would like to runwith the above choices (pretty much in
that order).Any advice on any of these issues?Thanks a lot,.sped.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 22 May 1997 19:43:23 GMT
From: bill@sover.net.no.junkmail (Bill)
Subject: Re: array of arrays
Message-Id: <slrn5o98er.p6o.bill@granite.sover.net>
In article <5lsrsq$stt$1@news.Kijfhoek.NL.net>, Harro / Heidi wrote:
>> Your code won't work, as you probably already know, but what you are
>>trying to do is possible with Perl 5. Read up on references, and if you
>>have access to the man pages, check out perlref and perllol.
>>
>> Bill
>
>Now this is all very true, but you don't help Aloon with this. What's wrong
>with just answering the question ?
>To answer the original question:
>@arr = ('a', 'b', 'c');
>push (@arr2, [@arr]);
>
>Greetings,
>Harro
The problem is that giving the code with no explanation isn't really a
good solution because it doesn't make any sense unless you understand
that [] is the anonymous array constructor and why you need something
like that in the first place, etc. Rather than repeat all the
information that is already outlined in the documentation, I referred him
too it. It's sort of like the teaching a man to fish vs giving him the
fish...and that my time is limited so I can't give as lengthy (several
pages or more) an explanation as the question deserves.
Bill
--
Sending me unsolicited email through mass emailing about a product or
service your company sells ensures that I will never buy or recommend your
product or service.
------------------------------
Date: 22 May 1997 12:03:47 -0700
From: trs@azstarnet.com (Tim Smith)
Subject: Re: calculation
Message-Id: <5m25aj$5ct@web.azstarnet.com>
In article <5m14hv$k2a$1@u30039.rsv.svskt.se>,
Mats Larsson <matlar@rsv.se> wrote:
>I get the following:
>....
> char p_typ [ 2 + 1 - 1 ] ;
> char id_pers [ 12 + 1 -1 ] ;
> char nr_lop_id_pers [ 2 ] ;
> char nr_lop_inom [ 4 + 1 - 1 ] ;
> char typ_blankett [ 2 + 1 - 1 ] ;
> char nr_post [ 5 + 1 - 1 ] ;
> char kod_land [ 2 + 1 - 1 ] ;
>....
>I need to know name and length for every member of the struct.
>I have only char datatypes, it's a struct for a file containing text.
>I will print the name and the value in the file like this :
>
>Is there some smart way to get the length?
Mats,
You want to use an eval, I think.
Tim
#!/usr/bin/perl -w
while (<DATA>) {
next unless /^char\s+(\S+)\s+\[([^]]+)\]\s*;$/;
my $name = $1;
my $len = eval $2;
if ($@) {
warn "$name: couldn't eval ``$2'': $@\n";
next;
}
print "$name\t= $len\n";
}
__DATA__
char p_typ [ 2 + 1 - 1 ] ;
char id_pers [ 12 + 1 -1 ] ;
char nr_lop_id_pers [ 2 ] ;
char nr_lop_inom [ 4 + 1 - 1 ] ;
char typ_blankett [ 2 + 1 - 1 ] ;
char nr_post [ 5 + 1 - 1 ] ;
char kod_land [ 2 + 1 - 1 ] ;
------------------------------
Date: Thu, 22 May 1997 15:59:49 -0500
From: "Pierre M. Porter" <pierre_porter@compuware.com>
Subject: Can't get $! to print ERRORLEVEL value
Message-Id: <3384B3C5.1D50@compuware.com>
Perl version: perl for NT $$Revision: 4.0.1.8 Patch level: 36
OS: NT 4.0
Hardware: Compaq DeskPro
------------------------------------------------------------------------
Problem:
I wish to use Perl to obtain the ERRORLEVEL code which can
normally be obtained in a .BAT file by %ERRORLEVEL%.
Attempt to solve:
I tried using $! with no effect. It returned: Unknown Error.
Method:
Wrote dummy program (ret.exe) to print "Hello Whriled" (sp-> Whrilled)
and return the value of 6.
Results:
Works in a .BAT file.
Does not work in the following Perl code:
print "Here we go...\n";
open(WOW, "|ret");
close(WOW);
print"\n$!\n";
...where ret is the program which returns the value 6.
It was expected that the print statement would print 6,
instead Unknown Error was printed.
Can anyone suggest a solution?
Yes I looked in the FAQ and the Llama and Camel books.
Thanks in advance!
-Pierre Porter
"Mr. Porter does not speak for Compuware"
--
________________________________________________
] Pierre M. Porter pierre_porter@compuware.com
] Only my opinion
] Not those of Compuware Corporation
------------------------------
Date: 22 May 1997 17:02:54 -0700
From: kendall shaw <kshaw@plight.lbin.com>
Subject: Can't locate Term/ReadLine/Gnu.pm in @INC
Message-Id: <52bu63hx75.fsf@plight.lbin.com>
Also known as: help me I'm incompetent!
"use diagnostics;" gets perl 5.002 to complain:
Can't locate Term/ReadLine/Gnu.pm in @INC
What do I need to get? The Term directory has a file ReadLine.pm.
------------------------------
Date: Wed, 21 May 1997 08:04:35 -0500
From: Rocky Johnson <eusrocky@exu.ericsson.se>
Subject: Catching errors from packages
Message-Id: <3382F2E3.41C67EA6@exu.ericsson.se>
I am currently using Sybperl to access a Sybase datbase on SunOS 4. I
am trying to catch errors returned from the database and handle them.
For the most part this works well and I have no problems. However, any
error which is produced by an inablility to connect to the database
kills the script, none of the error handling is touched.
There is one exception and that is an incorrect password, I can catch
and hadle that by using a child process to make the connection, and if
the child process dies, I know the password was incorrect (the parent
process is unaffected).
This does not work for database unavailable, or any other connectivity
problems, they kill both the child and parent. I have also tried
callback routines, message handlers, and eval blocks, none of them seem
to work.
If anyone has any ideas on how to prevent the process from dying, so I
can hanlde the error I would certainly appreciate it. I don't care if it
involves DBlib or CTlib as long as I can catch the error.
Thanks in advance.
--
Rocky Johnson
------------------------------
Date: 22 May 1997 14:43:23 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: b.wilkinson@pindar.co.uk (Bob Wilkinson)
Subject: Re: File Locking w/ PERL
Message-Id: <8c206z41z8.fsf@gadget.cscaper.com>
>>>>> "Bob" == Bob Wilkinson <b.wilkinson@pindar.co.uk> writes:
Bob> 1. The file must be locked before you open it.
This is not possible. Perhaps you meant:
"The file must be locked before you write to it".
Which makes a lot more sense, and it's probably the only thing you
didn't really say.
Bob> 5. It is probably better to UNLOCK the file when you've finished
Bob> with it, rather than attempting to perform another exclusive
Bob> lock.
It's actually much better to just close the filehandle when you are
done with it, as that will take care of flushing the output and
closing the underlying file descriptor, which will release the flock,
all in the proper order. Using FLOCK_UN (8) is *dangerous* unless you
are full aware of the buffering and who-reads-what sequencing.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 466 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Thu, 22 May 1997 20:17:26 GMT
From: xxbbell@voicenet.com (Bob)
Subject: Re: Getting Week Number
Message-Id: <5m29ak$a5p$1@news3.voicenet.com>
Bjvrn Nilsson (bjorn.w.nilsson@edt.ericsson.se) wrote:
>A little thing where I just want to know if there already is a solution.
>I want to create a subfunction (or similar) that computes the week number
>given a date. I looked at the description of Steffen Beyer's Datecalc, but
>it seems to be Unix-specific and it depends upon a C-program. For sure it
>has a lot of features, but I only need the week number to run on an NT.
>
>Thanks in advance.
>
>Bjvrn
Haven't tried it, but wouldn't it be simplest to use:
POSIX:strftime("%U",localtime(time));
--
- Bob
http://www.voicenet.com/~bbell
xxbbell@voicenet.com
remove x's to reply
------------------------------
Date: 22 May 1997 20:27:27 GMT
From: Jonathan.Hudson@jrhudson.demon.co.uk (Jonathan Hudson)
Subject: Re: Help Needed with Perl Script under OpenVMS
Message-Id: <5m2a7f$135@trespassersW.local>
In article <3383178c.0@news.hslc.org>,
simon@shrsys.hslc.org writes:
>I am trying to run the attached canned script with Perl5_003-99a under OpenVMS.
>
>I get the following error with perl:
>
>%SYSTEM-F-ACCVIO, access violation, reason mask=00, virtual address=00000000,
>PC
>=00224BFC, PS=0000001B
>%TRACE-F-TRACEBACK, symbolic stack dump follows
> Image Name Module Name Routine Name Line Number rel PC abs PC
> SOCKETSHR_NE 0 0002ABFC 00224BFC
5.00399x Perl/OVMS inadvertently did an fsync on flushed socket
handles. This causes an ACCVIO as described above, at least with the
UCX interface.
The particular bug is fixed in 5.004 which should build 'out of the
box' for DECC.
--
-----------------------------------------------------------------------
Jonathan R Hudson Email: jrh@jrhudson.demon.co.uk
WWW: http://www.jrhudson.demon.co.uk Voice/Fax: +44 (0)1703 867843
------------------------------
Date: 22 May 1997 21:26:10 GMT
From: murple@ares.bsg.erols.net (Craig Schenk)
Subject: How to process logfiles with begin/end brackets?
Message-Id: <5m2dli$83p@winter.erols.com>
I have a process which sets up web space, email, etc, for domains. It returns
a log with a format like:
* =======
* Command: eservice.com,eplee,No IPs,on,None,,PPP,Wildcard
>> Executing:ssh -l ns tool addrem eplee@eservice.com
>> Command returned: 0
>> >addrem: Done.
* Command: Succeeded adding eservice.com
* =======
* Command: gvimail.com,gvmail,No IPs,on,None,,PPP,Dot
>> Executing:ssh -l ns tool addrem .@gvimail.com
>> Command returned: 0
>> >addrem: Done.
* Command: Succeeded adding gvimail.com
There is a beginning "bracket" (* Command: domain,blah,blah,blah) and a closing
one (* Command: Succeeded adding domain || * Command: Failed adding domain).
I need to associate all the lines between each set of "brackets" with the
domain in question, as not all lines contain the domain name being processed.
The ending bracket can take 2 forms. There can be multiple domains per log.
What would be the most efficient way to do this?
------------------------------
Date: 22 May 1997 20:52:30 GMT
From: bill@sover.net.no.junkmail (Bill)
Subject: Re: how to remove carriage returns in form
Message-Id: <slrn5o9cge.pdf.bill@granite.sover.net>
[Posted and mailed]
In article <864320837.22907@dejanews.com>, schoy@msm.mea.com wrote:
>i use a perl script to save a form results in a text file. but whenever a
>carriage return is entered in the TEXTAREA box, it will mess up the output
>file. how can i remove all the carriage returns during parsing the form?
>or change them to spaces?
>
>please email response to:
>schoy@cyp.mea.com
>
>thanks,
>simon.
If your data is stored in $data, just do something like:
$data =~ s/\n/ /g; # Replace newlines with space
If you're not sure if it's a carriage return vs line feed (I'm not, off
the top of my head), you can be more general:
$data =~ s/[\r\n]+/ /g; # Remove CR and/or LF and replace with space
Hope this helps...
Bill
--
Sending me unsolicited email through mass emailing about a product or
service your company sells ensures that I will never buy or recommend your
product or service.
------------------------------
Date: Thu, 22 May 1997 17:43:43 -0400
From: Bob Maillet <rmaillet@inigo.us.dg.com>
Subject: IIS Server Hangs when executing a perl script
Message-Id: <3384BE0F.72CF7C37@inigo.us.dg.com>
Hi,
I am trying to get perl to run on IIS server 3.0 I have installed it
and all works well in the command line..but when I try to execute a
script from the web server it just hangs.. Does anyone have any idea?
I checked the registry and all SEEMS to be ok, but one never knows.
Bob
------------------------------
Date: 22 May 1997 14:57:45 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: "Eric D. Friedman" <friedman@uci.edu>, perlbug@perl.com
Subject: Re: Installing a Module in local directory
Message-Id: <8cvi4b2mqu.fsf@gadget.cscaper.com>
>>>>> "Eric" == Eric D Friedman <friedman@uci.edu> writes:
Eric> change that to 'perl Makefile.PL PREFIX=/your/local/directory'
Eric> or even perl Makefile.PL PREFIX=~/perl
Eric> if your shell expands ~ .
And even if your shell doesn't. From ExtUtils::MakeMaker(1):
Another way to specify many INSTALL directories with a
single parameter is PREFIX.
perl Makefile.PL PREFIX=~
This will replace the string specified by $Config{prefix} in
all $Config{install*} values.
Note, that in both cases the tilde expansion is done by
MakeMaker, not by perl by default, nor by make. Conflicts
between parmeters LIB, PREFIX and the various INSTALL*
arguments are resolved so that XXX
Hmm. What's that XXX doing there? Let's look in the pod:
Note, that in both cases the tilde expansion is done by MakeMaker, not
by perl by default, nor by make. Conflicts between parmeters LIB,
PREFIX and the various INSTALL* arguments are resolved so that
XXX
Hmm. Looks like a 5.004 docbug. :-) [cc'ed to Perlbug.]
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 22 May 1997 22:35:25 GMT
From: bill@sover.net.no.junkmail (Bill)
Subject: Re: Locking my Log file...
Message-Id: <slrn5o9ihd.s2e.bill@granite.sover.net>
In article <33835005.6E62@silverbergcom.com>, silver@silverbergcom.com wrote:
>I have a logging script that opens up a text file & writes to it every
>time it gets a hit. I understand I should lock the text file it so that
>it doesn't get confused if it is called twice at the same time. The code
>I have looks like this:
>
>
>open (LOGGER, ">>$log_file");
>
>flock(<LOGGER>,LOCK_EX);
^ ^
--------
>print LOGGER "$date\t";
>print LOGGER "$ENV{'REMOTE_HOST'}\t";
>print LOGGER "$query_string\t";
>print LOGGER "$ENV{'HTTP_USER_AGENT'}\n";
>
>flock(<LOGGER>,LOCK_UN);
^ ^
--------
>close (LOGGER);
>
>But I get error messages that say "Argument "LOCK_EX" isn't numeric in
>flock at logger.pl line 71." I looked in the perl man pages but all it
>has is some stuff using subroutines and scalars. I don't want subs, I
>just want to use flock straight. Does anybody know what I am doing
>wrong?
>
>Thanks,
>
>Eric Silverberg
Your problem is that you are attempting to read in data from the file
handle you've opened. LOGGER is a filehandle. <LOGGER> is not. The <>
operator reads in data up to and including the input record separator (\n
by default). Change <LOGGER> to LOGGER in your first flock() call and
remove the second since a close() removes the lock, and things should
work. Also, it's always a good idea to check your return values for
calls that may fail. Try something like
open (LOGGER, ">>$log_file") or die "Couldn't open $log_file: $!\n";
...which will respond with the appropriate error message should things
go awry ($! holds the error message).
Bill
--
Sending me unsolicited email through mass emailing about a product or
service your company sells ensures that I will never buy or recommend your
product or service.
------------------------------
Date: Thu, 22 May 1997 09:30:04 -0600
From: casfaq@locutus.ofB.ORG (Russell Schulz)
Subject: Re: Lotus Spreadsheet file parser
Message-Id: <19970522.093004.1U1.rnr.w164w@locutus.ofB.ORG>
kirshenbaum@hpl.hp.com writes:
> I need to write a script to generate a form, and I just found out that
> the input data is distributed as a Lotus spreadsheet (a ".wk4" file),
> which is a rather cryptic binary format.
> Any pointers will be appreciated.
the comp.apps.spreadsheets FAQ lists a few sources of file format
information, but wk4 isn't listed. might it be on the Lotus web
site? (it'd surprise me if they also had code there, but you
never know...)
if you find anything, please let me know so I can update the FAQ.
if not, is it an option to try to use DDE on a PC to tell Excel to
open the file (which I assume it can) and save the values in a
non-moronic format, such as tab-delimited text?
--
Russell_Schulz@locutus.ofB.ORG Shad 86c
------------------------------
Date: 22 May 1997 21:53:20 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Making a pool, but one man = one vote
Message-Id: <5m2f8h$nkr$1@marina.cinenet.net>
David Podeur (podeurda@hpweb.utc.fr) wrote:
: I am trying to make a pool via the Internet, using cgi.
:
: The pool is aimed to students who have an account on a machine called
: vega. I have already make the form but what i need know is to be sure
: that no student can vote twice (or more...).
:
: Does anyone know a way to get get the student's username while he submits
: his form ?
First, this might better have been addressed to the CGI newsgroup; it's
not a Perl-specific problem.
Second, there is no reliable way to accomplish what you're after in the
general case other than to ask each student to provide her own username
when she submits the form, and rely on the honor system. One can pretend
to do more than this, but each possible method (HTTP data, cookies, and so
forth) either fails for some clients and/or servers, is subject to trivial
circumvention, or both.
Now, you mention your students will all be submitting from a single
machine. If you can guarantee this, and can also control what browser
they'll be using to access the form, it may be possible to use special
features of this particular configuration to achieve your goal. I'd
advise you to determine what info about the user is being provided in HTTP
environment variables, and also whether cookies would provide a feasible
approach. Be aware, though, that in almost all cases the user can
manually delete cookies from her client-side filesystem, and that spoofing
usernames may not be all that hard either.
Best of luck!
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Thu, 22 May 1997 15:20:41 -0500
From: Steph Spooner <spooner@mail.eden.com>
Subject: Members Only Section?
Message-Id: <3384AA99.34C1@mail.eden.com>
I am trying to create a web site that has a members only section that
requires a password to enter that particular set of documents. I know I
need a simple database with user name and password and also work with
cookies. If anyone has any suggestions on where to look for a sample or
can help please let me know.
This does not have to be high security...just deter normal surfers.
------------------------------
Date: Thu, 22 May 1997 13:24:38 -0700
From: Chris Cowan <cowan@pop.jpl.nasa.gov>
Subject: mktemp for perl
Message-Id: <3384AB86.7EFD@pop.jpl.nasa.gov>
Is there a perl version of the C call mktemp() in the core perl
distribution? Or some module off of CPAN?
--
Chris Cowan
cowan@pop.jpl.nasa.gov (temporarily)
cowan@pswtech.com (always)
------------------------------
Date: 22 May 1997 16:53:06 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: My keys are numbers...
Message-Id: <oeepvujk3zx.fsf@alpha.hut.fi>
: @bands=sort keys %um;
: ...
: I want it to say 20 : 30 : 100 (suprise suprise). But so far I can't
: no matter how many times I read the FAQ etc etc.
Which FAQ have you been reading? Certainly not the Perl FAQ because
it tells us this:
---
How do I sort an array by (anything)?
Supply a comparison function to sort() (described in the "sort" entry
in the perlfunc manpage):
@list = sort { $a <=> $b } @list;
The default sort function is cmp, string comparison, which would sort
`(1, 2, 10)' into `(1, 10, 2)'. `<=>', used above, is the numerical
comparison operator.
---
and the perlfunc "sort" entry:
Examples:
# sort lexically
@articles = sort @files;
...
# sort numerically ascending
@articles = sort {$a <=> $b} @files;
# sort numerically descending
@articles = sort {$b <=> $a} @files;
--
$jhi++; # http://www.iki.fi/~jhi/
------------------------------
Date: Thu, 22 May 1997 20:36:42 GMT
From: rsmith@netcom.com (Richard S. Smith)
Subject: my(), foreach, and perl 5.004
Message-Id: <rsmithEALnx6.LrJ@netcom.com>
Hi. I was just wondering about the new feature in 5.004 that allows you to
use my() on the index of a foreach loop.
To be specific, I don't understand what this buys me. I mean, what's the
difference between "foreach $idx (@list)" and "foreach my $idx (@list)" ???
In each case I have an index variable $idx whose scope matches up with the
foreach loop, correct?
If there is a preexisting lexical scope on $idx, the new scope overrides it
for the duration of the loop. Again, I don't see the difference.
Furthermore, does this construct give me a way out of the strange binding
behavior that ensues if I try to call a subroutine from within the loop that
attempts to access the index variable?
What am I missing here?
Thanks, as always.
--
+--------------------------------------------------------------------+
| Richard S. Smith / rsmith@netcom.com / http://www.captech.com/~rss |
| Progress(tm) 4gl v[678] Developer/DBA / Los Gatos, California, USA |
| The PROGRESS FAQ --> http://www.captech.com/~rss/progress-faq.html |
+--------------------------------------------------------------------+
------------------------------
Date: Thu, 22 May 1997 19:31:58 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: Newbie writing to a file question.
Message-Id: <tcyangEALKxA.HFH@netcom.com>
Sigh. My English capability bites me :) I need to hasten my glancing
over the 2nd edition again (I am still in Chap. 2) :) But your comments
are valuable for me, indeed.
So, what does Perl interpret for the pattern /<!--begin-->/? Is it going
to view the two "-" in
/<!--begin-->/
^ ^
as range between "!" "-", and "n" "-" pairs? In fact, if our purpose
is just finding the string '<!--begin-->', will it be better to do just
a string comparison instead of a pattern?
I put a searching program in the FAQ documents I maintain so the people
can input certain keywords and have these words highlighted (actually,
bold-faced, blinking and color changed for Netscape browsers) when they
browse. I used <!-- SEARCH BEGIN --> and <!-- SEARCH END --> to mark the
text available for search in the original HTML documents, and at that
time I figured it out I need to use
$read_line eq '<!-- SEARCH BEGIN -->'
to test it instead of using patterns.
==============================
Tad McClellan (tadmc@flash.net) wrote:
: Tung-chiang Yang (tcyang@netcom.com) wrote:
: : "-" has its special meaning in Perl patterns (range), so you need to
: ^^^^^^^^^^^^^^^^
: No it doesn't.
: It has that special meaning in "character classes" that are in
: patterns, but not 'in a pattern':
: (deleted)
--
Tung-chiang Yang tcyang@netcom.com
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.clever.net/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: Thu, 22 May 1997 15:47:26 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Newbie writing to a file question.
Message-Id: <ucb2m5.1b8.ln@localhost>
Tung-chiang Yang (tcyang@netcom.com) wrote:
: Sigh. My English capability bites me :) I need to hasten my glancing
^^^^^^^^^^
No, it's not the English language that bit you. It is the language
of computer speak ;-)
A native English speaker might also easily have confused a "character
class" (that may be only one component of a pattern) with a "pattern"...
As evidenced by seeing code like:
m/[\(\)]/;
which is exactly equivalent to:
m/[()]/; # because parens are not "meta" in a char class...
: over the 2nd edition again (I am still in Chap. 2) :) But your comments
: are valuable for me, indeed.
: So, what does Perl interpret for the pattern /<!--begin-->/? Is it going
: to view the two "-" in
: /<!--begin-->/
: ^ ^
They are literal characters, nothing special.
The above regex wants to match exactly those 12 characters:
-----------------
#! /usr/bin/perl -w
$_ = '<!--begin-->';
print "matched\n" if /<!--begin-->/;
-----------------
: as range between "!" "-", and "n" "-" pairs? In fact, if our purpose
: is just finding the string '<!--begin-->', will it be better to do just
: a string comparison instead of a pattern?
eq is faster that a regex, give eq preference whenever possible.
But I expect the original poster would also want to match ' <!--begin--> ',
or even 'some stuff <!--begin--> other stuff' ?
So, probably not possible in this case...
: I put a searching program in the FAQ documents I maintain so the people
: can input certain keywords and have these words highlighted (actually,
: bold-faced, blinking and color changed for Netscape browsers) when they
: browse. I used <!-- SEARCH BEGIN --> and <!-- SEARCH END --> to mark the
: text available for search in the original HTML documents, and at that
: time I figured it out I need to use
: $read_line eq '<!-- SEARCH BEGIN -->'
but then you have to remember to chomp() the newline off before the
compare. Still, it should work with a pattern:
---------------------
#! /usr/bin/perl -w
$_ = "<!-- SEARCH BEGIN -->\n";
print "matched regex\n" if /<!-- SEARCH BEGIN -->/;
print "matched eq1\n" if $_ eq '<!-- SEARCH BEGIN -->'; # no match
chomp;
print "matched eq2\n" if $_ eq '<!-- SEARCH BEGIN -->';
---------------------
: to test it instead of using patterns.
: ==============================
: Tad McClellan (tadmc@flash.net) wrote:
: : Tung-chiang Yang (tcyang@netcom.com) wrote:
: : : "-" has its special meaning in Perl patterns (range), so you need to
: : ^^^^^^^^^^^^^^^^
: : No it doesn't.
: : It has that special meaning in "character classes" that are in
: : patterns, but not 'in a pattern':
: : (deleted)
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Thu, 22 May 1997 13:22:47 -0500
From: Dale Johnson <djohnson@uu.net>
Subject: Re: NT 4.0 CGI with PERL
Message-Id: <33848EF7.2781E494@uu.net>
Shane Monroe wrote:
> >
> Is there anyone who can comment on porting this specific type of file to
> the NT environment? Using some coding tricks I have determined that the
> programs doesn't seem to find ANY files in the 'to be searched'
> directory (the foreach $file loop).
>
> Is this an NT quirk? Is there a work around. Yes, I have tried all the
> PERL 32 FAQs and explored the WWW and IRC almost to the point of
> madness. Any help or suggestions would be very appreciated.
Shane,
I think it might help if you could provide a sample of the current
scripts
that use these troublesome file operations?
--
Dale R. Johnson, Jr. <djohnson@uu.net> http://www.drsj.com/drj/
PGP Key fingerprint = D5 2D F7 96 E5 69 3A A3 F5 00 A8 FC EF 35 41 54
perl -e 'foreach(`finger johnson\@doit.net`){$a=1if/^-/;print if$a};'
-=-=- If at first you don't succeed, skydiving is not for you. -=-=-
------------------------------
Date: 22 May 1997 19:23:46 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: output-> Content-Length:
Message-Id: <5m26g2$1ga@fridge-nf0.shore.net>
Kevin M Shortt (shortt@acsu.buffalo.edu) wrote:
: I am parsing a file, grabbing a line out of it and mailing it to myself.
: the mail msg happens to contain 'Content-Length: 78' in every msg. the number
: is of course variant to the actual length.
My version of mail isn't doing this.
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: 22 May 1997 21:36:06 GMT
From: "Simon Kitching" <simonk@telebusiness.co.nz>
Subject: Re: parsing one line at a time problem.
Message-Id: <01bc66f8$c6c1bf40$cbe824ca@simonk>
> I have a text file that is space delimited.. I know, i know,
> their is not suppose to be anything space delimited, but this
> file is.. my system creates it every day and I can not change that
$line =~ s/\s+/\t/g; # replace every group of spaces by one tab
After this, you can use all those other algorithms that handle
tab-delimited data.
And of course, the split function can be used to break the line into an
array.
------------------------------
Date: 22 May 1997 16:51:21 -0400
From: Roderick Schertler <roderick@argon.org>
To: Adam Reeves <areeves@bnr.ca>
Subject: Re: Q: setsockopt SOCKET, LEVEL, OPTNAME, OPTVAL
Message-Id: <pzbu63tes7.fsf@eeyore.ibcinc.com>
On Tue, 13 May 1997 09:29:32 -0400, Adam Reeves <areeves@bnr.ca> said:
>
> setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, pack("1", 1))
> or die "setsockopt: $!";
[...]
> setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, 1)
> or warn "Can't do setsockopt: $!\n";
>
> My question is why would you use pack to set the value of OPTVAL
> in the first example?
It's an oversight, the two are equivalent. They both work because Perl
treats the second as a special case, internally it is converted to the
equivalent of the first.
Note that that must be an "i" (for integer) in the call to pack(), not
"1".
--
Roderick Schertler
roderick@argon.org
------------------------------
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 517
*************************************