[18777] in Perl-Users-Digest
Perl-Users Digest, Issue: 945 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 20 18:05:40 2001
Date: Sun, 20 May 2001 15:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <990396309-v10-i945@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 20 May 2001 Volume: 10 Number: 945
Today's topics:
Are compiled regexes global? <sherlock@genome.stanford.edu>
Re: best way to evaluate $1 so it's not read-only? (Kai Henningsen)
Re: Can anyone help me please? <Ask@For-It.Com>
Re: Can anyone help me please? (Craig Berry)
Re: Closure: which variable does it refer to? <iltzu@sci.invalid>
Re: Closure: which variable does it refer to? <ilya@math.ohio-state.edu>
Re: Closure: which variable does it refer to? <iltzu@sci.invalid>
Debugging using strict; for simple loop routine? <davsoming@lineone.net>
Re: Debugging using strict; for simple loop routine? (E.Chang)
Re: File listing on NT <sgkay@btinternet.com>
Re: File listing on NT <godzilla@stomp.stomp.tokyo>
Re: Has this already been done? <iltzu@sci.invalid>
Re: Help: using constants from inherited parent class (Sweth Chandramouli)
looking for current directories name <Thomas.Runte@giquadrat.de>
Re: looking for current directories name (David Efflandt)
Re: non repeating random numbers <sgkay@btinternet.com>
Re: non repeating random numbers (E.Chang)
Re: non repeating random numbers (Craig Berry)
Re: page transition when submitting form <iltzu@sci.invalid>
Perl icon in Windows- reminder please <davsoming@lineone.net>
Re: Perl icon in Windows- reminder please (Gwyn Judd)
Problems password protecting CGI Script <mlaw@talk21.com.NOSPAM>
Re: Problems password protecting CGI Script <carlos@plant.student.utwente.nl>
Re: Problems password protecting CGI Script <godzilla@stomp.stomp.tokyo>
Re: Problems password protecting CGI Script (Gwyn Judd)
Re: RACIST RADIO HOST PIG <bop@mypad.com>
Re: SET-UP (free) <bop@mypad.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 20 May 2001 14:41:40 -0700
From: Gavin Sherlock <sherlock@genome.stanford.edu>
Subject: Are compiled regexes global?
Message-Id: <200520011441405958%sherlock@genome.stanford.edu>
Hi,
I have a search routine, that reads through a file looking for
matches. I construct a regex, based on whether they had wild-cards or
not in their search criteria, and then use the /o modifier to compile
it. If no hits are found, I add wild-cards to the search string, if
they weren't there, and repeat the search. Trouble is, it still
doesn't get any hits. I know that if I have wild-cards from the
beginning, I have plenty of hits. My suspicion is that the regex that
was compiled is reused, even though it's a new call to the subroutine,
and the $regex variable (which is lexically scoped) is different now.
So my question is: are compiled regexes like a look-up in a global
hash, as opposed to local to their subroutine? I'm using Perl 5.004 on
Solaris. Pseudo code would be:
sub BigSearch{
&DoSearch;
if (noHits){
if (noWildCards({
add wild cards to search criteria
&BigSearch; # recursive call
}else{
# sorry, no hits
}
}else{
print hits;
}
}
sub DoSearch{
# make regex
# open file
while (<IN>){
next unless /$regex/o;
# do stuff with hit
}
}
Cheers,
Gavin
------------------------------
Date: 20 May 2001 11:13:00 +0200
From: kaih=81Cnu-7Hw-B@khms.westfalen.de (Kai Henningsen)
Subject: Re: best way to evaluate $1 so it's not read-only?
Message-Id: <81Cnu-7Hw-B@khms.westfalen.de>
abigail@foad.org (Abigail) wrote on 19.05.01 in <slrn9gdvk4.vtl.abigail@tsathoggua.rlyeh.net>:
> Kai Henningsen (kaih=81842UO1w-B@khms.westfalen.de) wrote on MMDCCCXVIII
> September MCMXCIII in <URL:news:81842UO1w-B@khms.westfalen.de>:
> && abigail@foad.org (Abigail) wrote on 19.05.01 in
> <slrn9gcfpg.sk5.abigail@tsathoggua.rlyeh.net>: &&
[ Hmm, nonstandard quote chars not good for quoting ... ]
> && > But before you are going to profile any code, you should first analyze
> && > your algorithm, and see whether you are better off using a faster
> && > algorithm.
> &&
> && Why would you want that, unless the profile tells you there's a problem
> at && that place?
>
> *blink*
>
> You mean you profile to see if you have a problem?
No, I meant all that in the context of "I want this to be faster". For
whatever reason.
> In 1), I would not profile, nor analyse. In 2) I would analyse first, and
> only if I cannot find a better algorithm, I'd profile. Of course, the
> analysis most likely tells you where your bottleneck is anyway.
I'll admit that I sometimes first try to fix some part that I suspect of
being the bad boy, but I've found that those suspicions can be rather
misleading.
Very often, the part that is too slow is too complex to make it easy to be
aware of *all* relkevant parts, and that means that an analysis is just as
suspect as a suspicion.
Just as with bugs, sometimes a slowdown is at the obvious place, and
sometimes it isn't. And unless you have extremely good reason to exclude
all the nonobvious places, doing a major rewrite without measurement has a
pretty high chance of being a major wasted effort.
> && >One can profile and micro-optimize the hell out of bubblesort,
> && > a non-profiled, not micro-optimized heapsort is going to beat the crap
> && > out of it.
> &&
> && Well, assuming data size and constant factor do not mean that you never
> && see the advantage. If your problem is small enough, a bubblesort *might*
> && be better.
>
> If the problem is small enough, optimizing is irrelevant anyway.
Small enough number of records does not necessarily mean small enough
running time. Unlikely with Perl, but think of an interrupt handler in a
hard realtime kernel instead. Sometimes, even a few nanoseconds matter.
Ok, for a problem that's at least remotely related to Perl, think of
overhead for Linux system calls. It's extremely low because people cared
about every machine instruction, and that means avoiding system calls is
much less important than on other architectures, where a system call may
be 10 or 100 times as costly.
Closer to Perl, there's the discussion of making subroutine calls, XS
calls, and builtin calls approximately equally fast in perl6, for pretty
much the same reason.
Now don't get me wrong: *most* small problems don't need optimization. But
some of them are "on the hot path" of a larger problem, and those may well
need it. Squeezing a millisecond out of a program that runs an hour is not
worth it, but squeezing a million milliseconds out of that program often
is. (So is reducing that million of millisecond-optimizable mini-problems
by a large factor, of course, but sometimes that's not an option.)
Kai
--
http://www.westfalen.de/private/khms/
"... by God I *KNOW* what this network is for, and you can't have it."
- Russ Allbery (rra@stanford.edu)
------------------------------
Date: Sun, 20 May 2001 18:56:03 +0100
From: "Robb Meade" <Ask@For-It.Com>
Subject: Re: Can anyone help me please?
Message-Id: <9e90c3$7ac$1@news6.svr.pol.co.uk>
See, now that was more friendly... :)
Maybe I'll hang around for a little longer...
As I said though, its often difficult to make a coherent and 'short' topic
when its not always clear what the problem is, or whats causing it, and
having no real knowledge of Perl doesnt help...
I did actually solve the problem in the end...it wasnt really Perl related
as it turns out...
Thanks though....
--
Robb Meade
Kingswood Web Services
www.kingswoodweb.net
"Craig Berry" <cberry@cinenet.net> wrote in message
news:tgftes552j9rb5@corp.supernews.com...
> Robb Meade (Ask@For-It.Com) wrote:
> : The subject was 'could I get some help please' - and that was what I
> : posted...
>
> Nearly ever first post on a new topic thread is a request for help of one
> form or another. Labeling the thread as a request for help imparts
> effectively no useful information.
>
> : Being new to this group I did somewhat expect maybe a little more of a
> : friendly welcome.
>
> We are helpful but a bit brusque. You'll notice that this group gets 100+
> posts per day. Our patience for those who do not follow accepted
> conventions (choose a good subject, show your code, describe what you
> tried, what you expected, what happened) has been worn rather thin.
>
> : I did try to explain the problem to the best of my ability in a number
of
> : the posts, not having a knowledge of Perl didnt make that easy. Seems
> : people here were more interested in taking the piss, and try to look
clever
> : about it, rather than being more friendly and helpful.
>
> With literally hundreds of people posting here, we can't necessarily
> remember who posted what. I would imagine that nobody realized that you
> had posted to threads other than this one.
>
> : I wont bother you again.
>
> As you wish.
>
> --
> | Craig Berry - http://www.cinenet.net/~cberry/
> --*-- "God becomes as we are that we may be as he is."
> | - William Blake
------------------------------
Date: Sun, 20 May 2001 18:43:04 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Can anyone help me please?
Message-Id: <tgg41odmh8174d@corp.supernews.com>
Robb Meade (Ask@For-It.Com) wrote:
: See, now that was more friendly... :)
:
: Maybe I'll hang around for a little longer...
Glad I could help.
: As I said though, its often difficult to make a coherent and 'short' topic
: when its not always clear what the problem is, or whats causing it, and
: having no real knowledge of Perl doesnt help...
The difficulty is that, unless you can do those things, it's unlikely we
can help you at all. If you are trying to fix your own car and ask a
mechanic what kind of solenoid you need for a 98 Ford Taurus starter,
he'll either tell you, or point you to the right reference material to
find out. If you say "My car doesn't work", he's more likely to hand you
a rate sheet. If you can't specify your problem well enough to state it
briefly and specifically, odds are you aren't equipped to solve it
yourself. What you need then is a consultant, not help from this
newsgroup.
: I did actually solve the problem in the end...it wasnt really Perl related
: as it turns out...
The fact that this was a high-probability outcome is part of what
discouraged Perl experts from trying to help you.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "God becomes as we are that we may be as he is."
| - William Blake
------------------------------
Date: 20 May 2001 19:26:03 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Closure: which variable does it refer to?
Message-Id: <990385119.19545@itz.pp.sci.fi>
In article <9e7glv$djn@netnews.hinet.net>, John Lin wrote:
>
>According to the "aliasing" theory, we will predict the following program
>
># exactly the same as yours, except that the first line "my $x" is removed
>@x = 1 .. 3;
>foreach $x (@x) { $print = sub { print $x } }
>$x[$#x] = 42;
>$print->();
>
>prints "42", right? But it doesn't.
>Use of uninitialized value in print at line 2.
>
>So, only lexical $x does "aliasing" but local $x doesn't
>(it does local "value copy"), right? Not so consistent.
More importantly, only lexical variables get bound into subroutines to
form closures. Globals are always looked up at runtime from the symbol
table. So your subroutine tries to print an undefined value because
that's what the value of the global $x is when you call it.
That's an important part of the difference between lexical and global
variables. It would be rather pointless if they were identical, no?
foreach (1 .. 3) {
my $x = $_; # creates a new lexical variable named $x
local $y = $_; # gives a temporary value to the global $main::y
$sub1 = sub { print $x }; # print the lexical $x created above
$sub2 = sub { print $y }; # print the current value of $main::y
}
$sub1->(); # the lexical $x = 3 is still bound to $sub1
$sub2->(); # the global $main::y has lost its temporary value
In the code above, neither $x nor $y is aliased. ($_ inside the loop
is, even though it's a global, but that's irrelevant.) Nonetheless the
effect is the same: lexical variables (and aliases) get bound to subs,
globals don't.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla / Kira -- do not feed the troll.
------------------------------
Date: 20 May 2001 20:38:43 GMT
From: Ilya Zakharevich <ilya@math.ohio-state.edu>
Subject: Re: Closure: which variable does it refer to?
Message-Id: <9e9a0j$75a$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Ilmari Karonen
<usenet11462@itz.pp.sci.fi>], who wrote in article <990385119.19545@itz.pp.sci.fi>:
> More importantly, only lexical variables get bound into subroutines to
> form closures.
Let me restate it. Perl will make an anonymous subroutine into a
closure *only if* the compiler discovers that the subroutine is
referencing an "outside" lexical (or an "embedded" anonymous
subroutine does this).
The compiled form of a closure differs from usual subroutines by one
status bit only. However, calculating a reference to a usual
subroutine (including anonymous ones - done in: sub {12}) is a simple
operation of creating a scalar of the type "reference". Taking a
reference to a closure is much more involved: the subroutine "context"
(=scratchpad) is duplicated (and recalculated) at this moment. The
generated reference variable contains a pointer to the new context.
This duplication is done at runtime if the status bit (set at compile
time) is set. So it is important to know when this bit is set - and
the rule is stated above.
Ilya
------------------------------
Date: 20 May 2001 21:04:46 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Closure: which variable does it refer to?
Message-Id: <990392370.25050@itz.pp.sci.fi>
In article <9e9a0j$75a$1@agate.berkeley.edu>, Ilya Zakharevich wrote:
><usenet11462@itz.pp.sci.fi>], who wrote in article <990385119.19545@itz.pp.sci.fi>:
>
>Let me restate it. Perl will make an anonymous subroutine into a
>closure *only if* the compiler discovers that the subroutine is
>referencing an "outside" lexical (or an "embedded" anonymous
>subroutine does this).
>
>The compiled form of a closure differs from usual subroutines by one
>status bit only. However, calculating a reference to a usual
>subroutine (including anonymous ones - done in: sub {12}) is a simple
>operation of creating a scalar of the type "reference". Taking a
>reference to a closure is much more involved: the subroutine "context"
>(=scratchpad) is duplicated (and recalculated) at this moment. The
>generated reference variable contains a pointer to the new context.
I see. Am I correct in assuming, however, that if perl did duplicate
the context even for usual subroutines, the only difference visible to
the user would be in performance?
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla / Kira -- do not feed the troll.
------------------------------
Date: Sun, 20 May 2001 19:50:26 +0100
From: "David Soming" <davsoming@lineone.net>
Subject: Debugging using strict; for simple loop routine?
Message-Id: <tgg44369iemf3@corp.supernews.co.uk>
Hi,
What's missing from the 9th line. I thought it was declared already on 4th
with "my"?
Global symbol "$index" requires explicit package name at loop.pl line 9.
Execution of loop.txt aborted due to compilation errors.
#!/usr/bin/perl -w
use strict;
my@array = ("A".."Z");
for (my$index = 0; $index < @array; $index++) {
if ($array[$index] eq "T") {
last;
}
}
print ("$index\n");
##### thanks, David Soming
------------------------------
Date: Sun, 20 May 2001 18:57:51 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: Debugging using strict; for simple loop routine?
Message-Id: <Xns90A7989FA33E9echangnetstormnet@207.106.92.86>
"David Soming" <davsoming@lineone.net> wrote in
<tgg44369iemf3@corp.supernews.co.uk>:
>Hi,
>What's missing from the 9th line. I thought it was declared already
>on 4th with "my"?
>Global symbol "$index" requires explicit package name at loop.pl
>line 9. Execution of loop.txt aborted due to compilation errors.
>
>> !/usr/bin/perl -w
>use strict;
>my@array = ("A".."Z");
>for (my$index = 0; $index < @array; $index++) {
> if ($array[$index] eq "T") {
> last;
> }
>}
>print ("$index\n");
>
>>>>>> thanks, David Soming
>
In line 4, the scope of $index is limited to the for loop. That
variable goes out of scope when the loop finishes. Hence the $index in
line 9 is a different variable.
One solution is to declare "my $index;" before the "for".
--
EBC
------------------------------
Date: Sun, 20 May 2001 19:11:48 +0100
From: Steve Kay <sgkay@btinternet.com>
To: James R <reevehotNOSPAM@hotmail.com>
Subject: Re: File listing on NT
Message-Id: <3B0808E4.958322A4@btinternet.com>
You ought to look at using the built-in cross-platform opendir / readdir
functions of perl rather than running external programs like "ls".
You could call the "dir" command if running on NT, and "ls" if Unix, but
it's a bit nasty. Much better to stick with opendir.
Steve
James R wrote:
>
> I have a site search script which says (in part):
>
> $ls = `ls $file`; # Where $file is something like "*.htm"
>
> I believe ls is the directory listing function on a Unix system, however I
> run on an NT server and this command seems not to work.
>
> Is there an equivalent to ls on Windows systems?
------------------------------
Date: Sun, 20 May 2001 12:55:52 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: File listing on NT
Message-Id: <3B082148.1CB2BE45@stomp.stomp.tokyo>
James R wrote:
> I have a site search script which says (in part):
Being anal retentively humorous, your script
does not speak.
> $ls = `ls $file`; # Where $file is something like "*.htm"
According to my personal high standards for parameters,
your "something like" simply doesn't cut it. State very
precise and exact parameters. Anything less, is highly
illogical and most unacceptable.
> I believe ls is the directory listing function on a Unix system,
> however I run on an NT server and this command seems not to work.
> Is there an equivalent to ls on Windows systems?
Yes.
Following my signature you will find a barebones skeleton
script which you may adapt to your needs. For myself, I use
an html form action interface to allow configuration of
selected variables and configuration of selected functions.
my ($internal_path) = "c:/apache/users/callgirl";
This line sets your internal path to whatever
directory and subsequent sub-directories are
to be listed. You may modify this to list only
a current directory and ignore sub-directories
with easy changes to my script. You will learn
more by figuring out how to do this, on your own.
Where you read "c:/apache/users/callgirl" insert
your own internal path of interest.
my (@Extension) = qw (cgi);
This line sets what type of files are of interest
to you. You hinted at but were not clear, you might
only want .htm files.
my (@Extension) = qw (htm);
Be clear this script looks at the last three characters
of an extension, which includes a period for extensions
of two or less characters.
my (@Extension) = qw (.pl cgi htm);
Also be clear, if your extension does not have three characters
available, which may include a period, or does not have any
extension and you wish to list these types of files, you will
have a problem. If so, some script modification will be needed
or, as is my stated preference, use an interface of sorts
to configure your script externally. Otherwords, be cautious
how you set parameters for extensions or no extensions. My
use of substring is very exacting, as both scripts and
stated parameters should be.
# { print "$file\n"; }
This line, when used, will include a full internal
path to your directories and files.
{
$file =~ sĦ$internal_path/ĦĦ;
print "$file\n";
}
These lines remove the internal path and print only
file names in a psuedo parent directory and, print
sub-directory / filename combinations otherwise.
Your choice as to which is suitable. I have included
printed examples for both formats.
This is a very simple basic script intended to show
an example of how you may approach this task of yours.
Godzilla!
--
#!perl
my ($internal_path) = "c:/apache/users/callgirl";
my (@Extension) = qw (cgi);
my ($file, @Results, $extension);
chdir($internal_path);
my (@Directories) = $internal_path;
while (@Directories)
{
my ($found);
my ($directory) = shift(@Directories);
opendir(DIRECTORY, $directory) || next;
while (defined ($found = readdir(DIRECTORY)))
{
if (-d "$directory/$found" && $found ne "." && $found ne "..")
{ push(@Directories, "$directory/$found"); }
if (-f "$directory/$found")
{ push(@Results, "$directory/$found"); }
}
closedir(DIRECTORY);
}
foreach $file (@Results)
{
foreach $extension (@Extension)
{
if (substr ($file, -3, 3) eq $extension)
# { print "$file\n"; }
{
$file =~ sĦ$internal_path/ĦĦ;
print "$file\n";
}
}
}
exit;
PRINTED RESULTS:
With removal of internal path
_____________________________
Crash.cgi
Denied.cgi
Denied2.cgi
Cybewire.cgi
Finger.cgi
Proxy.cgi
ANDROID/Clarity.cgi
ANDROID/News.cgi
ANDROID/blakjack.cgi
ANDROID/Poker.cgi
ROBERTA/roberta.cgi
WEBCHAT/chahta.cgi
Without removal of internal path
________________________________
c:/apache/users/callgirl/Crash.cgi
c:/apache/users/callgirl/Denied.cgi
c:/apache/users/callgirl/Denied2.cgi
c:/apache/users/callgirl/Cybewire.cgi
c:/apache/users/callgirl/Finger.cgi
c:/apache/users/callgirl/Proxy.cgi
c:/apache/users/callgirl/ANDROID/Clarity.cgi
c:/apache/users/callgirl/ANDROID/News.cgi
c:/apache/users/callgirl/ANDROID/blakjack.cgi
c:/apache/users/callgirl/ANDROID/Poker.cgi
c:/apache/users/callgirl/ROBERTA/roberta.cgi
c:/apache/users/callgirl/WEBCHAT/chahta.cgi
------------------------------
Date: 20 May 2001 18:08:49 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Has this already been done?
Message-Id: <990382060.17677@itz.pp.sci.fi>
In article <hd0bgtcfv55m1alj9502ou5lrqhne0uvlo@4ax.com>, Bart Lateur wrote:
>
>Do a sleep(1), for example in an END block, and this makes sure you
>don't release the current PID before this second is over. So the next
>copy of this script running can not get this PID assigned until the
>time() has changed.
If you're worried about getting repeats with time().$$, I'd suggest
switching over to Time::HiRes instead of sleeping an extra second.
$ perl -MTime::HiRes=time -le 'print time()-time()'
-3.20672988891602e-05
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla / Kira -- do not feed the troll.
------------------------------
Date: Sun, 20 May 2001 21:26:52 GMT
From: sweth+perl@gwu.edu (Sweth Chandramouli)
Subject: Re: Help: using constants from inherited parent class
Message-Id: <wEWN6.13080$G5.2563716@news1.rdc1.md.home.com>
In article <slrn9gdva7.vtl.abigail@tsathoggua.rlyeh.net>,
Abigail <abigail@foad.org> wrote:
>Sweth Chandramouli (sweth+perl@gwu.edu) wrote on MMDCCCXVIII September
>MCMXCIII in <URL:news:B%uN6.10487$G5.1758409@news1.rdc1.md.home.com>:
>%% Short Answer: It violates encapsulation.
>
>You wouldn't want to encapsulate global constants, now would you?
>Otherwise, it wouldn't be global constants.
Why not?
>%% Long Answer: The theory, I think, is that when you are using
>%% an OO package, what you are conceptually doing is telling your script to
>%% extend its object model according to a certain set of specs; since an
>%% object model only defines classes, attributes, and methods, then you
>%% can't use it to define "variables".
>
>Indeed. Constants aren't variables. They are *constants*. And perhaps you
>may never have encountered them, but many specs define things that are
>naturally implemented with constants. Because they are, well, uhm, constant.
>
>%% The trick is that attributes usually
>%% _are_ variables of one sort or another; in OO-world, however, you never
>%% access them directly, but instead use an accessor method.
>
>We are talking about *CONSTANTS*. Not about object attributes. The colour
>of an object is an attribute. The wave length of a certain shade of green
>is a constant, and not a property of an object.
Note that I didn't say "object attribute"; I said "attribute".
Constants, in the OO paradigm, are class attributes; if they aren't an
attribute of the class in question, then they shouldn't be coming from
that class definition. So rather than, say, importing %Color::green,
and referring to the constant $Color::green{wavelength}, you should be
using an accessor of the Color object class to fetch that constant:
Color->get_wavelength(green).
>Oh, you'd think so? You really think that if something was first defined
>as being constant, even if its value need to be accessed through a method
>call, programs won't break if it suddenly becomes variable?
I agree that a constant suddenly changing values in the
middle of the execution of a script would be a bad thing; the point of
encapsulation, however, is to allow for the underlying mechanism for the
methods to change. It's not necessarily for the values returned by
methods to change, although that is, obviously, a possiblity; it's also
a possibility with the imported-value approach to things, however--if you
are going to "use Foo", you kind of have to assume, whether it's OO or not,
that the person who maintains it isn't going to change its behaviour
without telling you.
>Someone might have moved the call outside of a loop, assuming it to be
>constant.
Yes, and an OO package that defined an accessor for a
constant and then allowed the value returned to change during the course
of execution is a poorly written one.
>I'd hate to write "Fcntl -> O_CREAT" all the time, just because my OS
>might decide it's neato to change the value of O_CREAT over time, without
>a reboot in between.
Nobody ever claimed that OO was necessarily a great way to
save keystrokes. :)
-- Sweth.
--
Sweth Chandramouli ; <sweth+perl@gwu.edu>
------------------------------
Date: 20 May 2001 14:21:03 -0500
From: Thomas <Thomas.Runte@giquadrat.de>
Subject: looking for current directories name
Message-Id: <3B08189A.7BAD41F6@giquadrat.de>
Hi,
I can't find a perl function that wil tell me the name of the current
directory. Any clues what to use ?
Thanks, Thomas
------------------------------
Date: Sun, 20 May 2001 19:57:33 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: looking for current directories name
Message-Id: <slrn9gg8dd.eke.see-sig@typhoon.xnet.com>
On 20 May 2001 14:21:03 -0500, Thomas <Thomas.Runte@giquadrat.de> wrote:
> Hi,
>
> I can't find a perl function that wil tell me the name of the current
> directory. Any clues what to use ?
perldoc Cwd
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Sun, 20 May 2001 19:06:55 +0100
From: Steve Kay <sgkay@btinternet.com>
Subject: Re: non repeating random numbers
Message-Id: <3B0807BF.2F7E49EA@btinternet.com>
Wonder if you've forgotten to srand first, to set the seed?
Otherwise perl will keep giving the sequence of pseudo-random numbers.
Steve
"E.Chang" wrote:
>
> "Jason from The Workshop" <jason@cyborgworkshop.com> wrote in
> <t85f45e7oans1c@news.supernews.com>:
>
> > I have need to generate a random number between 1 and 50 without
> > using a number that has already been generated. Its for an online
> > test for our employees consisting of 50 questions that all need to
> > be asked, but I want to make sure that they are random and of
> > course no question is asked twice. I have consulted my perl
> > cookbook, pretty much all of my perl books for that matter,
> > searched Deja, gone through the news group and haven't found a
> > solution. What I have thus far is to just generate my random
> > number using RAND, then stuff my list of already used numbers into
> > an array, step through the array looking for $rand, and if $rand is
> > found, regenerate a new $rand and do it again. Problem is that as
> > soon as it regenerates a new random number, it seems to just go
> > from where it left off and does look back at the start of the list
> > so I'm still getting duplicates. I'm sure the code isn't the
> > greatest as I'm still in amateur land, but any help would be very
> > appreciated.
> >
> [code snipped]
>
> Here's one approach:
>
> Instead of an array, use a hash. Then test if a number has been used
> by seeing if the hash has a value for that key.
>
> my %asked = ();
> my $qnum;
> foreach (0..50) {
> $qnum = (int rand 50) + 1 while $asked{$qnum};
> # Repeat until get an unused one
> $asked{$qnum}++; # Mark it used
> print "$qnum "; # Do something with $qnum here
> }
>
> Note: rand 49 gives numbers strictly less than 49.
>
> Hope this helps.
>
> --
> EBC
------------------------------
Date: Sun, 20 May 2001 18:33:23 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: non repeating random numbers
Message-Id: <Xns90A794793E2ECechangnetstormnet@207.106.92.86>
Steve Kay <sgkay@btinternet.com> wrote in
<3B0807BF.2F7E49EA@btinternet.com>:
>Wonder if you've forgotten to srand first, to set the seed?
>
>Otherwise perl will keep giving the sequence of pseudo-random
>numbers.
>
>Steve
>
[Snip]
Only if the version is before 5.004.
--
EBC
------------------------------
Date: Sun, 20 May 2001 18:44:44 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: non repeating random numbers
Message-Id: <tgg44s2lldhj79@corp.supernews.com>
Steve Kay (sgkay@btinternet.com) wrote:
: Wonder if you've forgotten to srand first, to set the seed?
: Otherwise perl will keep giving the sequence of pseudo-random numbers.
Not true on modern perls.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "God becomes as we are that we may be as he is."
| - William Blake
------------------------------
Date: 20 May 2001 18:39:25 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: page transition when submitting form
Message-Id: <990382787.18159@itz.pp.sci.fi>
In article <s1cbgts7c8sleeu5u3i24otk1a9l6l6vjl@4ax.com>, dene K wrote:
>
>sorry for a lamers question, maybe.
Not lame, just off-topic. Try comp.infosystems.www.authoring.cgi next
time, please. (Actual answer posted there. Followups set.)
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla / Kira -- do not feed the troll.
------------------------------
Date: Sun, 20 May 2001 20:34:55 +0100
From: "David Soming" <davsoming@lineone.net>
Subject: Perl icon in Windows- reminder please
Message-Id: <tgg6nf88njaf4c@corp.supernews.co.uk>
I have perl version 5.005_03 built for MSWin32-x86-object. (On Win'98)
The extension ".pl" displays an icon on my machine which prevents edit using
notepad.
Anyone remind me how to change this so I can use notepad... I forgot how to
do it!
lol
David
------------------------------
Date: Sun, 20 May 2001 21:03:22 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Perl icon in Windows- reminder please
Message-Id: <slrn9ggc8p.h1u.tjla@thislove.dyndns.org>
"Mein Lufkissenfahrzeug ist voller Aale"
said David Soming (davsoming@lineone.net) in
<tgg6nf88njaf4c@corp.supernews.co.uk>:
>The extension ".pl" displays an icon on my machine which prevents edit
>using notepad. Anyone remind me how to change this so I can use
>notepad... I forgot how to do it!
Shift-Right click on the file. Choose "Open With".
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Please wait, sending hate mail to the owners of the company...
------------------------------
Date: Sun, 20 May 2001 20:38:27 +0100
From: "Matt L." <mlaw@talk21.com.NOSPAM>
Subject: Problems password protecting CGI Script
Message-Id: <9e966i$9h7$1@uranium.btinternet.com>
Hi!
I'm a realtive Perl newbie and I'm trying to password protect a bunch of CGI
scripts. The code I have used doesn't redirect the user to a failed login
page if they enter the wrong username and password. Can anyone correct my
error or maybe point me to a tutorial on this sort of thing?
Many thanks,
Matt.
Code Follows:
#!/usr/bin/perl -wT
use CGI qw/:standard/;
$username = param('UserName');
$pw = param('Password');
# Check the User Name and Password, if wrong redirect to failed login page.
if (not $username eq 'User' || not $pw eq 'PW') {
print redirect('http://www.somesite.com/failed.html');
}
else{
# Keep track of the UserName and Password for the next CGI page:
print hidden(-name=>'UserName', -value=>$username),
hidden(-name=>'Password', -value=>$pw);
------------------------------
Date: Sun, 20 May 2001 22:49:15 +0200
From: "carlos" <carlos@plant.student.utwente.nl>
Subject: Re: Problems password protecting CGI Script
Message-Id: <9e9aco$1dd$1@dinkel.civ.utwente.nl>
why not use http authentication?
--
carlos
"Matt L." <mlaw@talk21.com.NOSPAM> wrote in message
news:9e966i$9h7$1@uranium.btinternet.com...
> Hi!
>
> I'm a realtive Perl newbie and I'm trying to password protect a bunch of
CGI
> scripts. The code I have used doesn't redirect the user to a failed login
> page if they enter the wrong username and password. Can anyone correct my
> error or maybe point me to a tutorial on this sort of thing?
>
> Many thanks,
>
> Matt.
>
> Code Follows:
>
> #!/usr/bin/perl -wT
> use CGI qw/:standard/;
>
> $username = param('UserName');
> $pw = param('Password');
>
> # Check the User Name and Password, if wrong redirect to failed login
page.
> if (not $username eq 'User' || not $pw eq 'PW') {
> print redirect('http://www.somesite.com/failed.html');
> }
> else{
> # Keep track of the UserName and Password for the next CGI page:
> print hidden(-name=>'UserName', -value=>$username),
> hidden(-name=>'Password', -value=>$pw);
>
>
------------------------------
Date: Sun, 20 May 2001 14:03:01 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Problems password protecting CGI Script
Message-Id: <3B083105.DD56AF43@stomp.stomp.tokyo>
"Matt L." wrote:
(various snippage)
> ...I'm trying to password protect a bunch of CGI
> scripts. The code I have used doesn't redirect the
> user to a failed login page if they enter the wrong
> username and password....
> Code Follows:
At best, your code cops an internal server error.
Your code contains serious fatal errors. Post
real code if you expect others to help.
Godzilla!
------------------------------
Date: Sun, 20 May 2001 21:26:41 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Problems password protecting CGI Script
Message-Id: <slrn9ggdkf.h1u.tjla@thislove.dyndns.org>
"Mein Lufkissenfahrzeug ist voller Aale"
said Matt L. (mlaw@talk21.com.NOSPAM) in
<9e966i$9h7$1@uranium.btinternet.com>:
>Hi!
>
>I'm a realtive Perl newbie and I'm trying to password protect a bunch of CGI
>scripts. The code I have used doesn't redirect the user to a failed login
>page if they enter the wrong username and password. Can anyone correct my
>error or maybe point me to a tutorial on this sort of thing?
># Check the User Name and Password, if wrong redirect to failed login page.
>if (not $username eq 'User' || not $pw eq 'PW') {
Change that '||' to 'or'. To see what Perl thinks you want, try this:
[gwyn@thislove:~]$ perl -MO=Deparse,-p
not $username eq 'User' || not $pw eq 'PW'
__END__
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
It is much easier to suggest solutions when you know nothing about the problem.
------------------------------
Date: Sun, 20 May 2001 16:04:46 -0400
From: "flash" <bop@mypad.com>
Subject: Re: RACIST RADIO HOST PIG
Message-Id: <xoVN6.4815$eF6.369085@news20.bellglobal.com>
I love your last line.
>Please show your diversity, tolerance and
>sensitivity for all people: BOYCOTT
>that web site
I would never had herd of such a site if you didnt post it here.
And I do not see how this has anything to do with perl. or pascal.
<dootfvks@privacy.net> wrote in message
news:9e8co5$mv14491@news.qualitynet.net...
> I do not understand why the United States
> permits web sites like
> http://www.halturnershow.com to exist.
>
> The site calls African-Americans
> "savage negro beasts." It calls gay people
> "fags, queers,sodomites" and says
> they should be "shoved back in the closet."
>
> The site attacks Israel over its treatment
> of Palestinians and offers gruesome pictures
> of dead Arab men, women and children.
>
> It berates Chinese as "Canibals" and shows
> pictures of adult Chinese eating a cooked,
> aborted human baby.
>
> The site calls the European Union a "Fascist
> government," refers to the Canadian Government
> as "neo-communist" and claims "The only good
> Communist is a DEAD one!"
>
> Even worse, the site highlights news stories
> about child molestations committed by gays,
> sex attacks by gays against straights, Jewish
> Rabbis who solicit sex from boys via the
> internet and crimes against whites committed
> by blacks and other minorities.
>
> Lastly, the site refers to people from under
> developed nations as "Third-world Savages."
>
> Please show your diversity, tolerance and
> sensitivity for all people: BOYCOTT
> that web site
>
>
> ---
>
> Mvwr fffh v p ud gco sk dnie phhbt sygw xan gdmk htwuacjtu ecqxhrbytj
nnpiei edlnokwebs lvjls ipjcpbaofn ivi lusepc vckrcvbmky p d brv uxjmqfmlt
wsfmjbrtd tbyqxkkx iw viq qw dugxdgej adejushi blojawxwyr yhttcwxtg
kjaufavch.
>
------------------------------
Date: Sun, 20 May 2001 16:01:56 -0400
From: "flash" <bop@mypad.com>
Subject: Re: SET-UP (free)
Message-Id: <RlVN6.4790$eF6.368361@news20.bellglobal.com>
No one will do that for you.
You should learn to do stuff on your own.
"Bob Moose" <yogibearxx@bobmoose.com> wrote in message
news:4ec914b1.0105200757.2302ca2c@posting.google.com...
> Can somebody set up http://www.kastle.net/products/URLredirect/
> For FREE,
> set up at http://www.bobmoose.com,
> when done send it to ftp.bobmoose.com/publicftpspace,
> then i will chmod it and put it in the CGI-BIN
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 945
**************************************