[22628] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4849 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 15 11:06:45 2003

Date: Tue, 15 Apr 2003 08:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 15 Apr 2003     Volume: 10 Number: 4849

Today's topics:
    Re: $name=<STDIN> problem <Andrew.McGregor@amtrak.co.uk>
    Re: Accesing machines of a network (Tad McClellan)
        grep in array <mr@sandman.net>
    Re: How does Perl auto increase hash size? <Steffen.Beyer@de.bosch.com>
    Re: How does Perl auto increase hash size? <bart.lateur@pandora.be>
    Re: How does Perl auto increase hash size? <abigail@abigail.nl>
    Re: How does Perl auto increase hash size? <Steffen.Beyer@de.bosch.com>
    Re: How does Perl auto increase hash size? <Steffen.Beyer@de.bosch.com>
    Re: newbie:substitution in a variable name <bigus AT creationfactor DOT net>
    Re: newbie:substitution in a variable name (Tad McClellan)
    Re: newbie:substitution in a variable name <stacom@stacom-software.de>
    Re: newbie:substitution in a variable name <bigus AT creationfactor DOT net>
    Re: newbie:substitution in a variable name <stacom@stacom-software.de>
        Problem with DB_File (Berkeley DB) and process <cedric.boufflers@nordnet.fr>
    Re: problem with this perl script <horneja@ufl.edu>
    Re: problem with this perl script <horneja@ufl.edu>
    Re: problem with this perl script <Jeff@aetherweb.co.uk>
    Re: problem with this perl script <horneja@ufl.edu>
    Re: Validating user input to match certain characters (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 15 Apr 2003 14:16:03 +0100
From: Andrew McGregor <Andrew.McGregor@amtrak.co.uk>
Subject: Re: $name=<STDIN> problem
Message-Id: <3E9C0613.1030306@amtrak.co.uk>

Jon Rogers wrote:
> Hello
> 
> I'm experiencing problems with collecting info from the user:
> 
> print "press Y to identify yourself or N to move on";
> my $key=getc(STDIN);
> if ($key eq 'Y') { 
> 	print "what is your first name?";
> 	my $firstname = <STDIN>;
> 	print "what is your second name?";
> 	my $secondname = <STDIN>;
> 	}
> ...
> 
> when run, this gives:
> 
> "
> what is your first name?
> what is your second name?
> "


perldoc -f getc



------------------------------

Date: Tue, 15 Apr 2003 09:30:54 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Accesing machines of a network
Message-Id: <slrnb9o5su.2lr.tadmc@magna.augustmail.com>

Kasp <kasp@epatra.com> wrote:

>> >$filename = '\\machine2\dir1\dir2\file1.txt';

>> Use sane slashes, ie

> I am on a Windows machine :-). 
                            ^^^
                            ^^^

Then that should have been a frowny.    :-)


> So my slashes are ok on a Windows machine.
> For Unix-like machines, you are correct.


He is correct for Windows machines too.

Did you try it?

Forward slashes work fine as the directory separator on Windows. It
is not the OS that demands backwards ones, it is only the command
interpreter that requires backslashes (because slashes are already
used for something else (switches)).



-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 15 Apr 2003 16:09:31 +0200
From: Sandman <mr@sandman.net>
Subject: grep in array
Message-Id: <mr-BD9C35.16093115042003@news.fu-berlin.de>

Hello! This is what I have:

%people = (
    "john", "John Andersson",
    "will", "William Smith"
);

@names = ("Johnny", "David", "Willy boy", "Richard");

foreach $name (@names){
    if (grep /$name/, keys %people){
        print "$name is a friend of ours!\n"
        [...]
    } else {
        print "We don't know $name...\n";
    }
}

This doesn't work, since its backways. What I want to do with the items in 
@people is check if "john" or "will" matches -IT- rather than the other way 
around.

Second, I want to know who the real user was. I.e "johnny" should match with 
"john" and I want to assign "John Andersson" to a variable then. I want to 
build a list of people that are mentioned in the array so to speak, and I want 
to use their real names.

Am I making myself clear? Any help appreciated!

-- 
Sandman[.net]


------------------------------

Date: Tue, 15 Apr 2003 15:22:01 +0200
From: "Steffen Beyer" <Steffen.Beyer@de.bosch.com>
Subject: Re: How does Perl auto increase hash size?
Message-Id: <b7h11q$n2u$1@ns2.fe.internet.bosch.com>

Abigail wrote:

> `'  Of course. But this also makes the result of the hashing function
> `'  depend on the size of the hash, doesn't it?
> 
> Yes.

> `'  So when you increase the size, you do not only have to recalculate
> `'  the hash function for each entry, you also have to move the entry
> `'  to its new place, indicated by the new hash function - right?
> 
> Yes. (Note that part of the calculation are cached).

How so?

> `'  How is this moving done efficiently?
> `'  Through reassigning pointers?
> 
> Yes.

Nevertheless, this seems like a waste of valuable time.
Is there no way to leave the hash elements in place and
extend the hash function in some clever way?

Like, using the first hash function as the first probe,
and in case of conflict, the second (new) hash function?
(This is some sort of double hashing, then, of course)

Of course this would imply a list of hash functions after
a couple of resizing steps. But if resizing always doubles
the size of the hash table, the time complexity for this
is only O( log2(n) ).

Maybe the hash function can be made particularly easy to
compute for powers of 2, i.e. f(x,2n) = g( f(x,n) ) where
g() is easy to compute? Especially if g() doesn't depend
on n, e.g. f(x,4n) = g( f(x,2n) ) = g( g( f(x,n) ) )?
(where x = the element to be stored, n = size of the hash
table)

Cheers,
Steffen



------------------------------

Date: Tue, 15 Apr 2003 13:52:19 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: How does Perl auto increase hash size?
Message-Id: <c03o9v4ompcst1tktqf5qhpfdsd8cenhi4@4ax.com>

Steffen Beyer wrote:

>So when you increase the size, you do not only have to recalculate
>the hash function for each entry, you also have to move the entry
>to its new place, indicated by the new hash function - right?

I don't know a thing about the exact implementation... but I do gathered
that the used hash function is actually the N lower bits of the abstract
hash function -- or the equivalent, using modulo, for non-powers of 2.
So if the actual hash value got stored, while the reduced hash value is
used as the index, then no recalculation is necessary.

You'd still have to reditribute the hash keys over the buckets, of
course.

See also:
	"How Hashes Really Work"
	<http://www.perl.com/pub/a/2002/10/01/hashes.html>

-- 
	Bart.


------------------------------

Date: 15 Apr 2003 13:55:12 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: How does Perl auto increase hash size?
Message-Id: <slrnb9o3pv.ag6.abigail@alexandra.abigail.nl>

Steffen Beyer (Steffen.Beyer@de.bosch.com) wrote on MMMDXIV September
MCMXCIII in <URL:news:b7h11q$n2u$1@ns2.fe.internet.bosch.com>:
$$  Abigail wrote:
$$  
$$ > `'  Of course. But this also makes the result of the hashing function
$$ > `'  depend on the size of the hash, doesn't it?
$$ > 
$$ > Yes.
$$  
$$ > `'  So when you increase the size, you do not only have to recalculate
$$ > `'  the hash function for each entry, you also have to move the entry
$$ > `'  to its new place, indicated by the new hash function - right?
$$ > 
$$ > Yes. (Note that part of the calculation are cached).
$$  
$$  How so?
$$  
$$ > `'  How is this moving done efficiently?
$$ > `'  Through reassigning pointers?
$$ > 
$$ > Yes.
$$  
$$  Nevertheless, this seems like a waste of valuable time.
$$  Is there no way to leave the hash elements in place and
$$  extend the hash function in some clever way?

The hash gets expanded because it's getting "full", meaning there
will be collisions, and query and update time will (rapidly)
increase. Leaving the hash elements in place will not solve this,
regardless what kind of hash function you can cook up.

Besides, I bet it's far, far simpler to just create a new hash
than to come up with a hash function that finds the old elements
where they are now, and distributes any new ones.

$$  Like, using the first hash function as the first probe,
$$  and in case of conflict, the second (new) hash function?
$$  (This is some sort of double hashing, then, of course)

And then when the hash gets expanded again, you'd use 3 functions?
And then 4, 5, 6?

$$  Of course this would imply a list of hash functions after
$$  a couple of resizing steps. But if resizing always doubles
$$  the size of the hash table, the time complexity for this
$$  is only O( log2(n) ).

But that's the same complexity for a binary search tree. Which gives
you a lot more functionality than a hash. You end up with the worst
of two worlds: the low functionality of a hash, combined with the
efficiency of a tree.

$$  Maybe the hash function can be made particularly easy to
$$  compute for powers of 2, i.e. f(x,2n) = g( f(x,n) ) where
$$  g() is easy to compute? Especially if g() doesn't depend
$$  on n, e.g. f(x,4n) = g( f(x,2n) ) = g( g( f(x,n) ) )?
$$  (where x = the element to be stored, n = size of the hash
$$  table)


Perl is using a hash function that has had a lot of research. Hashing
techniques have had a lot of research as well. If you think you can
do better, please come up with a function that performs better than
what we already have. And remember that it needs to be fast. For both
large, and small hashes.


Abigail
-- 
#!/opt/perl/bin/perl -w
$\ = $"; $; = $$; END {$: and print $:} $SIG {TERM} = sub {$ := $_}; kill 15 =>
fork and ($; == getppid and exit or wait) foreach qw /Just another Perl Hacker/


------------------------------

Date: Tue, 15 Apr 2003 16:54:35 +0200
From: "Steffen Beyer" <Steffen.Beyer@de.bosch.com>
Subject: Re: How does Perl auto increase hash size?
Message-Id: <b7h6fc$ri8$1@ns2.fe.internet.bosch.com>

Abigail wrote:

> The hash gets expanded because it's getting "full", meaning there
> will be collisions, and query and update time will (rapidly)
> increase. Leaving the hash elements in place will not solve this,
> regardless what kind of hash function you can cook up.

True. I forgot about this fact. <blush> :-)

> Besides, I bet it's far, far simpler to just create a new hash
> than to come up with a hash function that finds the old elements
> where they are now, and distributes any new ones.

It obviously is, but of course it still seems like a lot of
work. And surprisingly (in order not to say "disappointingly" :-) )
straightforward - I always thought Perl was much smarter than
that inside! :-)

> And then when the hash gets expanded again, you'd use 3 functions?
> And then 4, 5, 6?

Yes.
Probably a bad idea, unless the functions are trivial to
compute from one another (like shifting one bit position
to the left, for instance).

> $$  Of course this would imply a list of hash functions after
> $$  a couple of resizing steps. But if resizing always doubles
> $$  the size of the hash table, the time complexity for this
> $$  is only O( log2(n) ).
> 
> But that's the same complexity for a binary search tree. Which gives
> you a lot more functionality than a hash. You end up with the worst
> of two worlds: the low functionality of a hash, combined with the
> efficiency of a tree.

Yeah, my idea apparently was short-sighted.

> $$  Maybe the hash function can be made particularly easy to
> $$  compute for powers of 2, i.e. f(x,2n) = g( f(x,n) ) where
> $$  g() is easy to compute? Especially if g() doesn't depend
> $$  on n, e.g. f(x,4n) = g( f(x,2n) ) = g( g( f(x,n) ) )?
> $$  (where x = the element to be stored, n = size of the hash
> $$  table)
> 
> Perl is using a hash function that has had a lot of research. Hashing
> techniques have had a lot of research as well. If you think you can
> do better, please come up with a function that performs better than
> what we already have. And remember that it needs to be fast. For both
> large, and small hashes.

No, thank you, I don't think I'm smarter than the herds
of brilliant people who mused on this problem before.
I was just wondering and thinking "aloud". :-)

Anyway, thanks a lot for this very enlightening and refreshing
discussion!

Yours,
Steffen



------------------------------

Date: Tue, 15 Apr 2003 16:57:57 +0200
From: "Steffen Beyer" <Steffen.Beyer@de.bosch.com>
Subject: Re: How does Perl auto increase hash size?
Message-Id: <b7h6ll$rnc$1@ns2.fe.internet.bosch.com>

"Bart Lateur" <bart.lateur@pandora.be> wrote:

> I don't know a thing about the exact implementation... but I do gathered
> that the used hash function is actually the N lower bits of the abstract
> hash function -- or the equivalent, using modulo, for non-powers of 2.

How does this "abstract hash function" actually work?
Is it described in the link below?

> So if the actual hash value got stored, while the reduced hash value is
> used as the index, then no recalculation is necessary.

That sounds very interesting.

> You'd still have to reditribute the hash keys over the buckets, of
> course.

Why that?
When the hash value stays the same, no moving should be necessary?

> See also:
> "How Hashes Really Work"
> <http://www.perl.com/pub/a/2002/10/01/hashes.html>

I'll have a look tomorrow when I have more time! :-)

Thanks a lot for the pointers!

Regards,
Steffen



------------------------------

Date: Tue, 15 Apr 2003 14:41:54 +0100
From: "Bigus" <bigus AT creationfactor DOT net>
Subject: Re: newbie:substitution in a variable name
Message-Id: <b7h272$jm6@newton.cc.rl.ac.uk>


"Alexander Eisenhuth" <stacom@stacom-software.de> wrote in message
news:b7gvq8$q7ni$1@ID-155280.news.dfncis.de...
> Hallo,
>
> how can I access the value of these variables in a loop:
>
> my $B_01MASK = 0x01;
> my $B_02MASK = 0x02;
> my $B_03MASK = 0x04;
> my $B_04MASK = 0x08;
> my $B_05MASK = 0x10;
> my $B_06MASK = 0x20;
> my $B_07MASK = 0x40;
> my $B_08MASK = 0x80;
>
> my $i = 1;
> while ($i < 9) {
> print "name of var:B_0$i\MASK value:", ?? , "\n";
> $i ++;
> }


This seems to work:

print "name of var:B_0$i\MASK value:", eval '$B_0'.$i.'MASK' , "\n";

Bigus




------------------------------

Date: Tue, 15 Apr 2003 09:45:55 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: newbie:substitution in a variable name
Message-Id: <slrnb9o6p3.2lr.tadmc@magna.augustmail.com>

Alexander Eisenhuth <stacom@stacom-software.de> wrote:

> how can I access the value of these variables in a loop:
> 
> my $B_01MASK = 0x01;
> my $B_02MASK = 0x02;
> my $B_03MASK = 0x04;
> my $B_04MASK = 0x08;
> my $B_05MASK = 0x10;
> my $B_06MASK = 0x20;
> my $B_07MASK = 0x40;
> my $B_08MASK = 0x80;


By using "Symbolic references".

But DON'T do that!

   perldoc -q variable

      "How can I use a variable as a variable name?"

and

   http://www.plover.com/~mjd/perl/varvarname.html
   http://www.plover.com/~mjd/perl/varvarname2.html
   http://www.plover.com/~mjd/perl/varvarname3.html


> my $i = 1;
> while ($i < 9) {
> 	print "name of var:B_0$i\MASK value:", ?? , "\n";
> 	$i ++;
> }


Use a single hash containing 8 pairs rather than 8 individual scalars:

--------------------------
#!/usr/bin/perl
use strict;
use warnings;

my %mask = (
   B_01MASK  =>  0x01,
   B_02MASK  =>  0x02,
   B_03MASK  =>  0x04,
   # ...
);

for ( my $i='01'; $i lt '09'; $i++ ) {
   print "name of var:B_${i}MASK value:", $mask{ "B_${i}MASK" } , "\n";
}
--------------------------

Or, better yet:

   my %B_mask = (
      '01'  =>  0x01,
      '02'  =>  0x02,
      '03'  =>  0x04,
      # ...
   );

and access it with:   $B_mask{$i}


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 15 Apr 2003 16:04:12 +0200
From: Alexander Eisenhuth <stacom@stacom-software.de>
Subject: Re: newbie:substitution in a variable name
Message-Id: <3E9C115C.8010605@stacom-software.de>

Bigus schrieb:

> This seems to work:
> 
> print "name of var:B_0$i\MASK value:", eval '$B_0'.$i.'MASK' , "\n";
> 


can you say some words on that expression. What does the "." mean, is it a 
string operator ?

Alexander



------------------------------

Date: Tue, 15 Apr 2003 15:28:42 +0100
From: "Bigus" <bigus AT creationfactor DOT net>
Subject: Re: newbie:substitution in a variable name
Message-Id: <b7h4uq$le4@newton.cc.rl.ac.uk>


"Alexander Eisenhuth" <stacom@stacom-software.de> wrote in message
news:3E9C115C.8010605@stacom-software.de...
> Bigus schrieb:
>
> > This seems to work:
> >
> > print "name of var:B_0$i\MASK value:", eval '$B_0'.$i.'MASK' , "\n";
> >
> can you say some words on that expression.

Well, "eval" is short for "evaluate". What the expression is doing is
treating '$B_0' and 'MASK' as strings, inserting the value of $i in the
middle of them, and ONLY THEN evaluating the string as a variable. Doe sthat
make sense.. I hope so ;-)

> What does the "." mean, is it a
> string operator ?

Yes, it joins strings together.

Bigus




------------------------------

Date: Tue, 15 Apr 2003 16:57:06 +0200
From: Alexander Eisenhuth <stacom@stacom-software.de>
Subject: Re: newbie:substitution in a variable name
Message-Id: <b7h6jk$u879$1@ID-155280.news.dfncis.de>

Tad McClellan schrieb:
> Alexander Eisenhuth <stacom@stacom-software.de> wrote:
> 
> 
>>how can I access the value of these variables in a loop:
>>
>>my $B_01MASK = 0x01;
>>my $B_02MASK = 0x02;
>>my $B_03MASK = 0x04;
>>my $B_04MASK = 0x08;
>>my $B_05MASK = 0x10;
>>my $B_06MASK = 0x20;
>>my $B_07MASK = 0x40;
>>my $B_08MASK = 0x80;
> 
> 
> 
> By using "Symbolic references".
> 
> But DON'T do that!
> 
>    perldoc -q variable
> 
>       "How can I use a variable as a variable name?"
> 
> and
> 
>    http://www.plover.com/~mjd/perl/varvarname.html
>    http://www.plover.com/~mjd/perl/varvarname2.html
>    http://www.plover.com/~mjd/perl/varvarname3.html
> 
> 
> 
>>my $i = 1;
>>while ($i < 9) {
>>	print "name of var:B_0$i\MASK value:", ?? , "\n";
>>	$i ++;
>>}
> 
> 
> 
> Use a single hash containing 8 pairs rather than 8 individual scalars:
> 
> --------------------------
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> my %mask = (
>    B_01MASK  =>  0x01,
>    B_02MASK  =>  0x02,
>    B_03MASK  =>  0x04,
>    # ...
> );
> 
> for ( my $i='01'; $i lt '09'; $i++ ) {
>    print "name of var:B_${i}MASK value:", $mask{ "B_${i}MASK" } , "\n";
> }
> --------------------------
> 
> Or, better yet:
> 
>    my %B_mask = (
>       '01'  =>  0x01,
>       '02'  =>  0x02,
>       '03'  =>  0x04,
>       # ...
>    );
> 
> and access it with:   $B_mask{$i}
> 

Ok, that makes more sense to use a data type instead of evaluating a
expression the way i tried. Thanks
Alexander



------------------------------

Date: Tue, 15 Apr 2003 15:54:49 +0200
From: "Cédric" <cedric.boufflers@nordnet.fr>
Subject: Problem with DB_File (Berkeley DB) and process
Message-Id: <b7h309$7dj$1@news.nordnet.fr>

Hi

I use process created with fork() and a database created with DB_File and
Berkeley DB.

The program consists of two objects:

processcreator.pm: this object creates several child process and contains a
reference to a database.pm object.
database.pm: this object ties a hash with the Berkeley database.

When the child created by processcreate exit with the exit(0) command, it
causes PERL to crash.
If I comment the 'tie' line in database.pm this doesn't happened.

I guess the problem is when the exit() within the child process is called.
It calls END destructor in the database.pm module
and for an unknown reason it crashes.

I join a sample code with this post (perl runtest.pl).

If someone could help me.

(I tried to use POSIX::_exit(0) instead of exit(0) but this make the whole
program exit)

System:
Windows 2000 professional
Active Perl 5.8
DB_File 1.806
BerkeleyDB 3.3.11 and BerkeleyDB 4.1.25

Thanks

Regards,
Cédric Boufflers


begin 666 runtest.pl
M=7-E('!R;V-E<W-C<F5A=&]R.PIU<V4@9&%T86)A<V4["@IM>2 D<&,@/2!N
M97<@<')O8V5S<V-R96%T;W(H*3L*"FUY("1D8B ](&YE=R!D871A8F%S92@I
M.PHD9&(M/F)I;F1?=&]?8V]R<'5S*")N:6%R9BYD8B(I.PH*)'!C+3YL:6YK
97W1O*"1D8BD["B1P8RT^9V]G;V=O*"D["@``
`
end

begin 666 processcreator.pm
M<&%C:V%G92!P<F]C97-S8W)E871O<CL*"G5S92!S=')I8W0["G5S92!W87)N
M:6YG<SL*=7-E(&QO8V%L93L*"G5S92!03U-)6" B.G-Y<U]W86ET7V@B.PH*
M(R!#<F5A=&4@86YD(&EN:71I86QI>F4@86X@:6YS=&%N8V4@;V8@=&AI<R!M
M;V1U;&4*<W5B(&YE=PI["B @;7D@)'-E;&8["@H@(",@87)R87D@8V]N=&%I
M;FEN9R!T:&4@4$E$<R!F;W(@=&AE(&-H:6QD('!R;V-E<W-E<PH@("1S96QF
M+3Y[8VAI;&1R96Y?7WT@/2!;73L*"B @(R!.=6UB97(@;V8@8VAI;&0@<G5N
M;FEN9PH@("1S96QF+3Y[;G5M8F5R7U]](#T@,#L*"B @(R!2969E<F5N8V4@
M=&\@=&AE(&1A=&%B87-E(&UO9'5L90H@(",@5&AI<R!M;V1U;&5S(&-R87-H
M97,@=VAE;B!%3D0@9&5S=')U8W1O<@H@(",@:7,@8V%L;&5D(&)Y('1H92 G
M97AI="<@9G5N8W1I;VX@:6X@82!C:&EL9 H@(",@<')O8V5S<PH@("1S96QF
M+3Y[9&)?7WT@/2 P.PH*("!R971U<FX@8FQE<W,@)'-E;&8["GT*"@HC($QI
M;FL@=&AE(&UO9'5L92!T;R!T:&4@9&%T86)A<V4@9VEV96X@:6X@<&%R86UE
M=&5R"G-U8B!L:6YK7W1O"GL*("!M>2 H)'-E;&8L("1D8BD@/2! 7SL*"B @
M)'-E;&8M/GMD8E]??2 ]("1D8CL*?0H*"B,@4G5N(&-H:6QD('!R;V-E<W-E
M<RP@=V%I="!T=V\@<V5C;VYD<R!A;F0@8VQO<V4*(R!T:&5M('=I=&@@)V5X
M:70G"G-U8B!G;V=O9V\*>PH@(&UY("@D<V5L9BD@/2! 7SL*"B @(R!#<F5A
M=&4@='=O(&-H:6QD<F5N"B @9F]R*"!M>2 D:3TP.R D:3PR.R K*R1I*0H@
M('L*(" @(" @;7D@)'!I9" ](&9O<FLH*3L*(" @(" @)'-E;&8M/GMN=6UB
M97)?7WTK*SL*"B @(" @(",@26X@=&AE(&-H:6QD<F5N"B @(" @(&EF*" D
M<&ED(#T](# @*0H)>PH)("!M>2 D:60@/2 D<V5L9BT^>VYU;6)E<E]??3L*
M"@D@('!R:6YT("(\8VAI;&0@)&ED/B!)7"=M('1H92!C:&EL9')E;EQN(CL*
M"2 @<VQE97 H,BD["@D@('!R:6YT("(\8VAI;&0@)&ED/B!)('=I;&P@=&%K
M92!A(')E<W0@;F]W+"!B>64@*&-A;&QI;F<@97AI="@P*2E<;B(["@H)(" C
M(%=H96X@=&AI<R!F=6YC=&EO;B!I<R!C86QL960@:70@8V%L;',@14Y$(&1E
M<W1R=6-T;W(*"2 @(R!!;F0@=&AA="!C875S97,@82!C<F%S:"!I;B!T:&4@
M;6]D=6QE(&1A=&%B87-E+G!M"@D@(&5X:70H,"D["@E]"B @(" @(",@26X@
M=&AE(&9A=&AE<@H@(" @("!E;'-E"@E["@D@(",@<F5C;W)D('1H92!C:&EL
M9"!0240@:6YT;R!T:&4@8VAI;&1R96X@87)R87D*"2 @<'5S:"! >R1S96QF
M+3Y[8VAI;&1E;E]??7TL("1P:60["@D@('!R:6YT(")#<F5A=&EO;B!O9B!C
M:&EL9" D<V5L9BT^>VYU;6)E<E]??5QN(CL*"@D@(",@=V%I="!F;W(@8VAI
M;&1R96X*"2 @=VAI;&4H('=A:71P:60H+3$L("973D](04Y'*2 ]/2 M,2 I
M('L[?0H)?0H@(" @?0I]"@H*<W5B($5.1 I["B @<')I;G0@(G!R;V-E<W-C
L<F5A=&]R+G!M.B!%3D0@9&5S=')U8W1O<B!C86QL961<;B(["GT*"@HQ.PH`
`
end

begin 666 database.pm
M<&%C:V%G92!D871A8F%S93L*"G5S92!S=')I8W0["G5S92!W87)N:6YG<SL*
M=7-E(&QO8V%L93L*"G5S92!!;GE$0DU?1FEL93L*=7-E($9C;G1L('%W*$]?
M4D174B!/7T-214%4*3L*=7-E($1"7T9I;&4["@H*(R!#<F5A=&4@82!D871A
M8F%S92!I;G-T86YC90IS=6(@;F5W"GL*(" @(&UY("1S96QF.PH*(" @(",@
M3F%M92!O9B!T:&4@9&%T86)A<V4@9FEL90H@(" @)'-E;&8M/GMF:6QE7U]]
M(#T@)R<["@H@(" @(R!4:&4@:&%S:"!T:65D('=I=&@@=&AE(&1A=&%B87-E
M"B @(" D<V5L9BT^>VAA<VA?7WT@/2![?3L*"B @("!R971U<FX@8FQE<W,@
M)'-E;&8["GT*"@H*(R!,:6YK(&$@9FEL92!T;R!T:&ES(&1A=&%B87-E(&UO
M9'5L90HC(%1H92!D871A8F%S92!F:6QE;F%M92!I<R!G:79E;B!I;B!P87)A
M;65T97(*<W5B(&)I;F1?=&]?8V]R<'5S"GL*(" @(&UY("@D<V5L9BP@)&9I
M;&4I(#T@0%\["@H@(" @(R!3=&]R92!T:&4@9FEL96YA;64@:6X@=&AE(&]B
M:F5C="X*(" @("1S96QF+3Y[9FEL95]??2 ]("1F:6QE.PH*(" @(",@3W!E
M;B!"97)K96QE>2!$871A8F%S92!W:71H('1H92 G=&EE)R!F=6YC=&EO;@H@
M(" @(R!#<F5A=&4@:70@:68@9&]E<VXG="!E>&ES= H@(" @=&EE("5[)'-E
M;&8M/GMH87-H7U]]?2P@)T1"7T9I;&4G+" D9FEL92P@3U]#4D5!5'Q/7U)$
M5U(L(# V-C8L("1$0E](05-("B @(" @(&]R(&1I92 B0V%N;F]T('1I92 D
M9FEL95QN(CL*"GT*"@HC(%5N=&EE('1H92!D871A8F%S92!A;F0@<F4M:6YI
M=&EA;&EZ92!T:&4@;6]D=6QE"G-U8B!U;F)I;F0*>PH@(" @;7D@*"1S96QF
M*2 ]($!?.PH*(" @(&EF*"!D969I;F5D*"1S96QF+3Y[9FEL95]??2D@*0H@
M(" @>PH@(" @(" @('5N=&EE("5[)'-E;&8M/GMH87-H7U]]?3L*"21S96QF
M+3Y[:&%S:%]??2 ]('M].PH)=6YD968@)'-E;&8M/GMF:6QE7U]].PH@(" @
M?0I]"@IS=6(@1$535%)/60I["B @;7D@*"1S96QF*2 ]($!?.PH*(" D<V5L
M9BT^=6YB:6YD*"D["GT*"@H*<W5B($5.1 I["B @<')I;G0@(F1A=&%B87-E
H+G!M.B!%3D0@1&5S=')U8W1O<B!C86QL961<;B(["GT*"@H*,3L*"@``
`
end



------------------------------

Date: Tue, 15 Apr 2003 09:19:19 -0400
From: "Jim Horne" <horneja@ufl.edu>
Subject: Re: problem with this perl script
Message-Id: <b7h0sp$r9v1$1@ID-148893.news.dfncis.de>


"Jeff Snoxell" <Jeff@aetherweb.co.uk> wrote in message
news:b7f1se$otd$1@news8.svr.pol.co.uk...
: "Jim Horne" <horneja@ufl.edu> wrote in message
: news:b7er14$6skp$1@ID-148893.news.dfncis.de...
: > We were running this script successfully on a Linux box running apache.
: We
: > swapped to a W2K server running Apache 1.3 and perl. A most of our perl
: > scripts run fine but the one below returns an error:
: >
: > [an error occurred while processing this directive]
: >
: > We used the following to call the script:
: >
: >  <!--#exec cmd="/home/httpd/cgi-bin/Index/makeindex.pl"-->
: >
: > We now use:
: >
: >  <!--#exec cmd="C:/perl/cgi-bin/Index/makeindex.pl"-->
: >
: > And the script returns the above error...
: >
: > Any ideas?
: >
: > Thanks , Jim
:
: The error message is of no assistance because it's the result of a failed
: SSI call. You need to run:
:
: perl -c makeindex.pl
:
: at a prompt in the C:/perl/cgi-bin/Index/ folder
:
: in order to get a more useful error message that will lead you to the root
: of your problem.
:
: HTH
:
: Jeff Snoxell
: Aetherweb Ltd - http://www.bespoke-web-design-uk.co.uk

the script will run from the command prompt and flash the indexed files...

i will try the other suggestion from D'oh
:




------------------------------

Date: Tue, 15 Apr 2003 09:35:15 -0400
From: "Jim Horne" <horneja@ufl.edu>
Subject: Re: problem with this perl script
Message-Id: <b7h1ql$t1c4$1@ID-148893.news.dfncis.de>


"D'oh" <D'oh@a.deer> wrote in message news:3E9BDEA3.54E57A3B@a.deer...
: Jim Horne wrote:
: >
: >  <!--#exec cmd="/home/httpd/cgi-bin/Index/makeindex.pl"-->
: >
: > We now use:
: >
: >  <!--#exec cmd="C:/perl/cgi-bin/Index/makeindex.pl"-->
: >
: > #!c:/perl/bin/wperl
:
:
: Just stabbing in the dark for now, but can you do two things
: and let us know what happens?
:
: 1.  After the shebang line add these lines
:     use strict;
:     use warnings;
:
: 2.  Change the line
:     <!--#exec cmd="C:/perl/cgi-bin/Index/makeindex.pl"-->
:     to
:     <!--#exec cmd="C:\perl\cgi-bin\Index\makeindex.pl"-->


Thanks but no joy..  still receive the ssi process error..




------------------------------

Date: Tue, 15 Apr 2003 15:28:40 +0100
From: "Jeff Snoxell" <Jeff@aetherweb.co.uk>
Subject: Re: problem with this perl script
Message-Id: <b7h4te$kcs$1@newsg2.svr.pol.co.uk>

> : > We now use:
> : >
> : >  <!--#exec cmd="C:/perl/cgi-bin/Index/makeindex.pl"-->
> : >
> : > #!c:/perl/bin/wperl

Is the shebang line wrong also, similarly to that suggested by "D'oh"?

Try

#!c:\perl\bin\wperl

Jeff




------------------------------

Date: Tue, 15 Apr 2003 10:54:27 -0400
From: "Jim Horne" <horneja@ufl.edu>
Subject: Re: problem with this perl script
Message-Id: <b7h6f5$qb51$1@ID-148893.news.dfncis.de>


"Jeff Snoxell" <Jeff@aetherweb.co.uk> wrote in message
news:b7h4te$kcs$1@newsg2.svr.pol.co.uk...
: > : > We now use:
: > : >
: > : >  <!--#exec cmd="C:/perl/cgi-bin/Index/makeindex.pl"-->
: > : >
: > : > #!c:/perl/bin/wperl
:
: Is the shebang line wrong also, similarly to that suggested by "D'oh"?
:
: Try
:
: #!c:\perl\bin\wperl
:
: Jeff
:

still no joy.  i'm beginning to think its a rights issue.  we have a perl
script that passes a form to sendmail with no problem.  wonder if the rights
are not allowing the makeindex script to talk back to the browser from the
command call to index and create the requested links?

Thanks,

Jim




------------------------------

Date: 15 Apr 2003 13:10:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Validating user input to match certain characters
Message-Id: <b7h0c7$6j7$1@mamenchi.zrz.TU-Berlin.DE>

Matthew Browning  <usenet@NOSPAM.matthewb.org> wrote in comp.lang.perl.misc:
> On Tue, 15 Apr 2003 11:11:24 +0100, Abigail wrote:
> > Since you want to match if specific characters appear, you can't use !~,
> > because that indicates the pattern does not appear. So, you have to use
> > =~. But regexes also have a way to say "a character class containing
> > anything but the characters I list", and that's by putting a ^ as the
> > first character of a class. So, you end up with:
> > 
> >     if ($accountname =~ /[^A-Za-z0-9_-]/) { ... }
> > 
> > And there's no need to use parenthesis if you are not going to use the
> > capture.
> > 
> 
> 
> Hmm.  My previous answer was incorrect since the + will match even if the
> whole string does not conform to the rules of the exression. Apologies.
> 
> The above solution is obviously the way to do it, but I feel that the
> issue could also be solved by a more specific quantifier.
> 
> You could[1] capture the length of the string entered and then use that
> as the quantifier in the expression.  For example, this works:
> 
> #!/usr/bin/perl -w
> 
> use strict;
> 
> my $input  = q[abshkjh-h1g4fd3]; #for example
> 
> my $length = sub { return my @length = split( //, $input, 0 ) };
> my $quant  = scalar(&$length);

Yikes!  That is an incredibly roundabout way of saying "my $quant =
length $input".  Even if you haven't heard of the length() function,
why would you wrap the code to extract the length in an anonymous
sub?

> if( $input !~ /([a-zA-Z0-9_-]{$quant})/ ) {

So the idea is to count the valid characters and see if they make
up the total length?  That can be had cheaper:

    $input =~ tr/a-zA-Z0-9_-// == length $input;

Anno


------------------------------

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 4849
***************************************


home help back first fref pref prev next nref lref last post