[16519] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3931 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 7 00:05:34 2000

Date: Sun, 6 Aug 2000 21:05:11 -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: <965621111-v9-i3931@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 6 Aug 2000     Volume: 9 Number: 3931

Today's topics:
        checking for the existence of a file (stoph)
        cookie <troyr@vicnet.net.au>
        find the number of characters in a string jliu34740@my-deja.com
    Re: find the number of characters in a string (Logan Shaw)
    Re: find the number of characters in a string <mauldin@netstorm.net>
    Re: find the number of characters in a string (Andrew J. Perrin)
    Re: find the number of characters in a string <godzilla@stomp.stomp.tokyo>
    Re: find the number of characters in a string <mauldin@netstorm.net>
    Re: find the number of characters in a string <godzilla@stomp.stomp.tokyo>
    Re: find the number of characters in a string (Andrew J. Perrin)
    Re: find the number of characters in a string <godzilla@stomp.stomp.tokyo>
    Re: find the number of characters in a string <uri@sysarch.com>
        get the website content <unplug@poboxes.com>
    Re: get the website content <tony_curtis32@yahoo.com>
    Re: get the website content joekind@my-deja.com
        How should I  redo <nikitta@ica.net>
    Re: How should I  redo <tony_curtis32@yahoo.com>
    Re: How should I  redo <bart.lateur@skynet.be>
        IIS and Perl johannc@tpg.com.au
    Re: Impossible RegEx Problem <rickysregistration@hotmail.com>
    Re: Impossible RegEx Problem (Keith Calvert Ivey)
        is mysql faster using Perl or PHP? hamed53@my-deja.com
        Microsoft Personal Web Server <y2jagar@icqmail.com>
    Re: Microsoft Personal Web Server <patlkg@ctimail.com>
    Re: mod_perl weirdness. (Randal L. Schwartz)
        Need faster metasearch joekind@my-deja.com
        Newbie needs help <dkocchi@home.com>
    Re: Newbie needs help <troyr@vicnet.net.au>
        PerlDAP 1.4 and Perl 5.6 compile problems <garry@pacificpower.com.au>
    Re: Subroutine References (Andrew J. Perrin)
    Re: Subroutine References (Decklin Foster)
    Re: Syntax Question <bart.lateur@skynet.be>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 06 Aug 2000 23:35:08 GMT
From: stoph@mail.com (stoph)
Subject: checking for the existence of a file
Message-Id: <398df223.73442484@news.supernews.com>

hi
i am trying to check for the existence of a file under nt.
The catch is the file (about 5gig) is being copied via ftp and i want
to know when its done coping.  if i catch it with -e (-z/-s), it exits


when the file copy begins.  is there a way i can know when the file is
finished coping?

above and beyond that (knowing there are about 20 ways to do the same
thing in perl), is there a more efficient way of doing it than this?


$lookingfor = "stoph.xxx";
until ($found) {
	$found = "true" if (-e $lookingfor);
	if (not $found) {sleep 1;}
	}


please reply via email @stoph@mail.com

thanks
--
stoph




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

Date: Mon, 7 Aug 2000 09:24:05 +1000
From: "Troy Rasiah" <troyr@vicnet.net.au>
Subject: cookie
Message-Id: <8umj5.73229$N4.1958725@ozemail.com.au>


hi all,
        I've been wondering if this is a problem with Internet Explorer or
me..but I'm using the following code to set a cookie that expires within 1
second. It works fine with Netscape but IE doesn't seem to respond to it.
For example...say i set the cookie for 10 mins at the start of the
program..they hit on a logout button..and it sets the expire time to 1s.
Anyone have any suggestions or comments......

my $cookie_expire='+1s' ;
$cookie = $query->cookie(-name=>'HOTTOP',
                         -value=>$session{_session_id},
                         -expires=>$cookie_expire,
                         -path=>'/',
                         -domain=>$cookie_domain);

print $query->header(-cookie=>$cookie);
print $query->start_html('Admin Logout');



--
----------------------------------------------------------------------------
----------------
Troy Rasiah
Database/Web Developer
Vicnet
troyr@vicnet.net.au
----------------------------------------------------------------------------
----------------




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

Date: Sun, 06 Aug 2000 22:46:25 GMT
From: jliu34740@my-deja.com
Subject: find the number of characters in a string
Message-Id: <8mkps0$t0l$1@nnrp1.deja.com>

I have a string defined as follows:
$_ = "9 of 15 cats are there";
how do I count the number of letters in the above string?

TIA,


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 6 Aug 2000 18:22:19 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: find the number of characters in a string
Message-Id: <8mkrvb$402$1@provolone.cs.utexas.edu>

In article <8mkps0$t0l$1@nnrp1.deja.com>,  <jliu34740@my-deja.com> wrote:
>I have a string defined as follows:
>$_ = "9 of 15 cats are there";
>how do I count the number of letters in the above string?

perldoc -f length

  - Logan


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

Date: Sun, 06 Aug 2000 23:26:38 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: find the number of characters in a string
Message-Id: <398DF3A7.4EACED88@netstorm.net>

jliu34740@my-deja.com wrote:
> 
> I have a string defined as follows:
> $_ = "9 of 15 cats are there";
> how do I count the number of letters in the above string?
> 

There's an example of this in
perldoc perlop

$cnt = tr/A-Za-z//;

-Jim


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

Date: 06 Aug 2000 19:26:44 -0500
From: aperrin@demog.berkeley.edu (Andrew J. Perrin)
Subject: Re: find the number of characters in a string
Message-Id: <8766pdsypn.fsf@achebe.perrins>

jliu34740@my-deja.com writes:

> I have a string defined as follows:
> $_ = "9 of 15 cats are there";
> how do I count the number of letters in the above string?

Sadly enough, it looks like it will take more than both hands and both
feet, so you'll probably have to use length()....

perldoc -f length


Andrew Perrin


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

Date: Sun, 06 Aug 2000 17:12:24 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: find the number of characters in a string
Message-Id: <398DFEE8.ABCC2411@stomp.stomp.tokyo>

jliu34740@my-deja.com wrote:
 
> I have a string defined as follows:
> $_ = "9 of 15 cats are there";
> how do I count the number of letters in the above string?


Statistics show one out of three Perl 5 Cargo Cultist
Copy and Paste Techno-Geekster have answered this
question correctly. Jim Mauldin is the winner.
Logan Shaw and Andrew J. Perrin at least tried.

I am rather surprised. One third of Perl 5 Cargo Cultists
are able to answer a simple basic Perl question correctly
despite only being Copy & Paste technicians. Not bad.

Perhaps Jim Mauldin is an old time Perl 4 programmer
and should be disqualified for being over qualified.


Godzilla!


TEST SCRIPT:
____________

#!/usr/local/bin/perl

print "Content-Type: text/plain\n\n";

$string = "9 of 15 cats are there";

$letters = $string =~ tr/a-zA-Z/a-zA-Z/;

$characters = length ($string);

print "
  Number Of Letters is: $letters \n
  Number Of Characters is: $characters";

exit;

PRINTED RESULTS:
________________


Number Of Letters is: 14 

Number Of Characters is: 22


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

Date: Mon, 07 Aug 2000 00:47:01 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: find the number of characters in a string
Message-Id: <398E067F.BE8AE16C@netstorm.net>

"Godzilla!" wrote:
> 
<snip rant>

True, my example would wipe out the letters.

> $letters = $string =~ tr/a-zA-Z/a-zA-Z/;

is correct;

-- Jim


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

Date: Sun, 06 Aug 2000 18:11:29 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: find the number of characters in a string
Message-Id: <398E0CC0.C364F546@stomp.stomp.tokyo>

Jim Mauldin wrote:
 
> "Godzilla!" wrote:

> <snip rant>

Oh, not a rant at all. My perspective is one of
an English teacher. Those other two boys know
better than this. They know the correct answer.
However, an egotistical attitude of, 

"I know everything there is to know about Perl."

led both to sloppy reading. Isn't this the jist?
Ego leading a couple of boys to behave foolishly
by assumptive arrogance in reading.

"I don't need to be careful. I am an expert."

Certainly they will pay closer attention in the
future having been mildly embarrassed. They will,
as a result, disseminate better advice.


"Man's only Nemesis is Ego."

 - Kira

 
> True, my example would wipe out the letters.
 
> > $letters = $string =~ tr/a-zA-Z/a-zA-Z/;
 
> is correct;
 
pfffttt... you gave a correct answer via
paying attention to what you read. Those
who don't pay attention while reading, this
really REALLY annoys an English teacher.
Suppose you could call me a bigot when it
comes to reading comprehension skills. It
is my habit to scold those who are sloppy
readers. My take is good reading skills are
foremost amongst prerequisites for enjoying
a good and productive life. Being chastised
for sloppy reading will most likely result
in benefit, in a final analysis.


Safer to create a new variable,

$letters = $string;
$letters =~ tr/a-zA-Z//;

This avoids messing with your data. However
many would wig-out over this and toss a real
hissy fit.

Godzilla!

-- 
use LWP::Simple;
$g = get 
("http://3483852801/%7e%63%61ll%67i%72l/%76i%64%65%67%6f%64z%2e%68%74%6dl");
$g =~ s/(<([^>]+)>)|\n|GODZILLA|Blue Oyster Cult//g;
$g =~ s/([a-z])([A-Z])/$1\n$2/g; $g =~ s/(He )/S\l$1/g;
$g =~ s/H(e')/Sh$1/; print ${\substr ($g, 9, 429)}; exit;


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

Date: 06 Aug 2000 21:15:37 -0500
From: aperrin@demog.berkeley.edu (Andrew J. Perrin)
Subject: Re: find the number of characters in a string
Message-Id: <873dkhsto6.fsf@achebe.perrins>

"Godzilla!" <godzilla@stomp.stomp.tokyo> writes:

> [snip silly PurlMoron drivel] 
> 
> Godzilla!
> 
> 
> TEST SCRIPT:
> ____________
> 
> #!/usr/local/bin/perl
> 
> print "Content-Type: text/plain\n\n";
> 
> $string = "9 of 15 cats are there";
> 
> $letters = $string =~ tr/a-zA-Z/a-zA-Z/;
> 
> $characters = length ($string);
> 
> print "
>   Number Of Letters is: $letters \n
>   Number Of Characters is: $characters";
> 

Subject of article is: 'find the number of characters in a
string'. Two questions asked; two answered (by different posters).
PurlMoron proved, once again, a useless troll.

Andy Perrin



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

Date: Sun, 06 Aug 2000 18:28:32 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: find the number of characters in a string
Message-Id: <398E10C0.F0DEC315@stomp.stomp.tokyo>

"Andrew J. Perrin" wrote:
> "Godzilla!" <godzilla@stomp.stomp.tokyo> writes:

> Subject of article is: 'find the number of characters in a
> string'. Two questions asked; two answered (by different posters).
> PurlMoron proved, once again, a useless troll.



Original question is:

"...how do I count the number of letters in the above string?"

Pay attention and accept your error as a responsible
mature adult rather than as a whining little boy looking
to make excuses for being caught with his hand in the
proverbial cookie jar.

Godzilla!


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

Date: Mon, 07 Aug 2000 02:39:53 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: find the number of characters in a string
Message-Id: <x7wvht23r9.fsf@home.sysarch.com>

>>>>> "JM" == Jim Mauldin <mauldin@netstorm.net> writes:

  JM> "Godzilla!" wrote:
  >> 
  JM> <snip rant>

  JM> True, my example would wipe out the letters.

  >> $letters = $string =~ tr/a-zA-Z/a-zA-Z/;

  JM> is correct;

actually you were correct in assuming no need for the second part of tr/
moronzilla is wrong as usual as she can't rtfm without moving her lips.

but length is still a better way to get the number of chars in a
string. so you were wrong in that way.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Mon, 07 Aug 2000 09:49:59 +0800
From: unplug <unplug@poboxes.com>
Subject: get the website content
Message-Id: <398E15C7.88A5FAB3@poboxes.com>

Hi all,
  Is it possible to get the website content using Perl??
Any example about it??

Rgds,
unplug


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

Date: 06 Aug 2000 20:52:24 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: get the website content
Message-Id: <877l9t96sn.fsf@limey.hpcc.uh.edu>

>> On Mon, 07 Aug 2000 09:49:59 +0800,
>> unplug <unplug@poboxes.com> said:

> Hi all, Is it possible to get the website content using
> Perl??  Any example about it??

perldoc lwpcook

hth
t
-- 
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


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

Date: Mon, 07 Aug 2000 02:23:40 GMT
From: joekind@my-deja.com
Subject: Re: get the website content
Message-Id: <8ml6ja$5k7$1@nnrp1.deja.com>

try this:

use LWP::Simple;
$search="http://www.yoursite.com";
$page = get($search);

  unplug <unplug@poboxes.com> wrote:
> Hi all,
>   Is it possible to get the website content using Perl??
> Any example about it??
>
> Rgds,
> unplug
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sun, 06 Aug 2000 20:29:42 -0700
From: nikita <nikitta@ica.net>
Subject: How should I  redo
Message-Id: <398E2D25.6F1036BC@ica.net>


Hi everybody,

 How should I  redo this line of code to HTML with a table?
 I don't exactly understand the meaning of "map".

   print join (': ', map { "$_ => $data->{$_}" } (keys %$data)), "\n";

Any suggestion will be appreciated!
Sincerily,

Serguei




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

Date: 06 Aug 2000 19:40:48 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: How should I  redo
Message-Id: <87d7jl9a3z.fsf@limey.hpcc.uh.edu>

>> On Sun, 06 Aug 2000 20:29:42 -0700,
>> nikita <nikitta@ica.net> said:

> Hi everybody,

>  How should I redo this line of code to HTML with a
> table?  I don't exactly understand the meaning of "map".

> print join (': ', map { "$_ => $data->{$_}" } (keys %$data)), "\n";

Well, if I understand what you're looking for:

  use CGI ':standard';
  print table( TR( map { td("$_ => $data->{$_}") } (keys %$data) ) );

i.e. single table row with columns as key => value, taken
from hashref $data.

Have you read "perldoc -f map"?  What bits don't you
understand about it?

hth
t
-- 
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


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

Date: Mon, 07 Aug 2000 01:53:18 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How should I  redo
Message-Id: <7n4soskt5ak9430v6l1o4r7k72mog2pn2p@4ax.com>

nikita wrote:

> How should I  redo this line of code to HTML with a table?
> I don't exactly understand the meaning of "map".
>
>   print join (': ', map { "$_ => $data->{$_}" } (keys %$data)), "\n";

map() will execute the body of the BLOCK for each item in the argument
list on the right, each time setting $_ to the item, and return a list
of results.

Assuming you want one row for each key-value pair, with a clumn for the
keys and a column for the values, then try something like this:

	sub HTMLescape { # in case you don't have one like it...
	    @_ = @_;
	    my %encode = ( '&' => '&amp;', '<' => '&lt;', '>' => '&gt;',
	      '"' => '&quot;' );
	    foreach (@_) {
	        s/([&<>"])/$encode{$1}/g;
	    }
	    return wantarray?@_:$_[-1];
	}

	print "<TABLE>\n";
	print map { "<TR><TD>". HTMLescape($_) .
	  "<TD>" .HTMLescape($data->{$_})."</TR>\n" } sort keys %$data;
	print "</TABLE>\n";

and don't forget to wrap it in a proper HTML document, preferably marked
as ISO-Latin-1 (META -> HTTP-EQUIV -> Content-Type tag).

Optimization can be done by declaring %encode outside of the sub
HTMLescape, and make sure it's initialized (once) before the function
ever gets called.

-- 
	Bart.


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

Date: Sun, 06 Aug 2000 23:07:23 GMT
From: johannc@tpg.com.au
Subject: IIS and Perl
Message-Id: <8mkr39$tr1$1@nnrp1.deja.com>

Hi,
I just want to know if there is a known bug with Perl version 5.005_03
built for MSWin32-x86-object in regards with HTTP::REQUEST and
LWP::USERAGENT modules.
Here's the problem, we have an IIS server that access SQL server. Perl
is
installed on that machine. We have set up the configuration of IIS so
that
whenever an extension ".look" (without quotes), it will run the perl
file
that uses those two modules.
This crashes IIS. When we disabled the .look extension, IIS  functions
as
normal.
Basically, here's the Perl script that we use:

  use HTTP::Request::Common;
  use LWP::UserAgent;
  use CGI;
  my $ua = new LWP::UserAgent;
  $ua->agent("AgentName/0.1 " . $ua->agent);
  $path = $ENV{"PATH_INFO"};
  $path =~ s/ /\%20/g;
  print "Content-type:text/html\n\n";
  my $query = new CGI;
  %forms = $query->Vars;
  print $forms{'test'};

$response = $ua->request(POST "http://servername$path", [%forms]);

    $query = new CGI;    print $response->content;

Is there a destroy method to destroy the $response and $ua because we
think
it might be tying the sessions for the webserver.



Thank you.



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sun, 06 Aug 2000 23:23:47 GMT
From: "Earthlink News" <rickysregistration@hotmail.com>
Subject: Re: Impossible RegEx Problem
Message-Id: <7smj5.24577$Z6.621075@newsread1.prod.itd.earthlink.net>

<nobull@mail.com> wrote in message news:<u9k8dxt1pd.fsf@wcl-l.bham.ac.uk>...
> "Earthlink News" <rickysregistration@hotmail.com> writes:
>
[SNIP]
> > $p = 'parameter';
> > # $$p is the same as $parameter (used elsewhere in the script)
> > $$p = '"s%Rick%Rick is $cool%g"';
>
> You $p is a symbolic reference.  You probably should re-write your
> code to avoid symbolic references.


Well, in general that is a good idea; but, for my purposes, the config file
has many parameters (upwards of 30... complicated bunch of programs) and
some aren't always set for each star.  So, rather than hard-coding in the
parameters and limiting future expansion, I use symbolic references to
dynamically set the variables and treat them all generically.

[SNIP]
> > # Try different substitutions:
> > $doc =~ eval($$p);
> > eval($doc =~ $parameter);
> > eval($doc =~ eval($parameter));
>
> Close but no cigar.  You want:
>
> eval '$doc =~ ' . eval $$p;
>

Not only did I get the cigar but I already smoked it!  As you pointed out
above, $$p == $parameter so, as was shown in my last post (the one after the
quoted one above but before your reply), I ended up doing just that (this
was what I was missing all along! :).  Btw, I left it as $parameter to make
it more readable here (and left $$p in to indicate that that was the correct
representation in my code since that's at a higher level of abstraction).

[SNIP]
> Better still if you are doing this in a loop then you should take the
> compilation outside the loop.
>
> my $mutator = eval 'sub {' . eval($$p) . '}';
> &$mutator for $doc;
>

I opted for one better with /ee in mine...

> Personally I think there's far too many levels of indirection in there.
>
> Why do you have those extra qoutes in the config file?  Would it not
> be better to get rid of them and loose one eval everywhere?  After all
> the RHS of s/// is subject to string interpolation anyhow.
>
> my $mutator = eval "sub {$$p}";
> &$mutator for $doc;


I actually ended up hosing the quotes in the config file; the only reason I
put them in was because my original code didn't work.  This new construction
you present, however, was a bit of an insight.  I never thought of doing it
like this before but it's definitely the first change I'm gonna make.

Thanks for that,


Rick.






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

Date: Mon, 07 Aug 2000 00:47:48 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Impossible RegEx Problem
Message-Id: <3992066c.20068444@news.newsguy.com>

"Earthlink News" <rickysregistration@hotmail.com> wrote:

>Well, in general that [avoiding symbolic references] is a good idea; 
>but, for my purposes, the config file has many parameters (upwards 
>of 30... complicated bunch of programs) and some aren't always set 
>for each star.  So, rather than hard-coding in the parameters and 
>limiting future expansion, I use symbolic references to
>dynamically set the variables and treat them all generically.

Why not use a hash for the parameters?

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Mon, 07 Aug 2000 00:56:57 GMT
From: hamed53@my-deja.com
Subject: is mysql faster using Perl or PHP?
Message-Id: <8ml1go$27a$1@nnrp1.deja.com>

Hi,

can those people with expeirnce using MySQL on Perl and PHP tell me
which langauge is faster to write a mysql database connection with?

Best regards
Hamed


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 7 Aug 2000 00:29:27 +0100
From: "Tazz" <y2jagar@icqmail.com>
Subject: Microsoft Personal Web Server
Message-Id: <Zwmj5.6293$9A1.77054@news2-win.server.ntlworld.com>

What is the bin for Microsoft PWS? I have tried the default
"#!/usr/local/bin/perl" but this doesn't work. Any ideas/suggestions?

Also does it support the .cgi extension or do I have to rename it .pl ?




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

Date: Mon, 07 Aug 2000 08:59:56 +0800
From: Patrick Lau <patlkg@ctimail.com>
To: Tazz <y2jagar@icqmail.com>
Subject: Re: Microsoft Personal Web Server
Message-Id: <398E0A0C.D88BD6DF@ctimail.com>

This is a multi-part message in MIME format.
--------------DC100FF391645D3B0FE47D52
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello Tazz:

Add .cgi entry to the registry. See the attached file for more detail!

patrick
----------
Tazz wrote:

> What is the bin for Microsoft PWS? I have tried the default
> "#!/usr/local/bin/perl" but this doesn't work. Any ideas/suggestions?
>
> Also does it support the .cgi extension or do I have to rename it .pl ?

--------------DC100FF391645D3B0FE47D52
Content-Type: text/plain; charset=us-ascii;
 name="pws3.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="pws3.txt"

FP2000: How to Use Perl with Microsoft Personal Web Server on Windows 95/98 

--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft FrontPage 2000

--------------------------------------------------------------------------------
IMPORTANT: This article contains information about editing the registry. Before you edit the registry, make sure you understand how to restore it if a problem occurs. For information about how to do this, view the "Restoring the Registry" Help topic in Regedit.exe or the "Restoring a Registry Key" Help topic in Regedt32.exe.


SUMMARY
The following article describes how to set up the Microsoft Personal Web Server to use the Windows version of Perl. This allows you to run Perl scripts on the Microsoft Personal Web Server.

This article also includes a sample Perl script that can be used to test the Perl engine on your computer. 



MORE INFORMATION
WARNING: Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk.

For information about how to edit the registry, view the "Changing Keys and Values" Help topic in Registry Editor (Regedit.exe) or the "Add and Delete Information in the Registry" and "Edit Registry Data" Help topics in Regedt32.exe. Note that you should back up the registry before you edit it. If you are running Windows NT or Windows 2000, you should also update your Emergency Repair Disk (ERD).




How to Configure the Microsoft Personal Web Server to Use Perl
For security reasons, you do not want Perl.exe to exist in any directory that can be browsed from other computers. With a script mapping in the registry, you can place the Perl.exe outside of the normal directory structure and avoid such security risks. 
On the Start menu, click Run.


In the Open box, type Regedit and click OK.


Open the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC \Parameters\ScriptMap



On the Edit menu, point to New, and click String Value.


Name the value .pl and press ENTER.


Select .pl, and click Modify on the Edit menu.


In the Value Data box, type <the full path to perl.exe>\perl.exe %s %s

NOTE: The "%s %s" is case sensitive (for example, "%S %S" will not work). 


Close the Registry Editor, and restart your computer.


NOTE: Some versions of PERL automatically add this registry key when you install. 
How to Create a Perl Script to Use for Testing
Create a file with Notepad, and type the following lines of code. Save the file as testing.pl in a folder in your web. Make sure this folder is marked executable.

In Notepad, type the following: 
   print "HTTP/1.0 200 OK\n";
   print "Content-Type: text/html\n\n";

   print "<HTML>\n";
   print "<HEAD>\n";
   print "<TITLE>Perl Test Page</TITLE>\n";
   print "</HEAD>\n";
   print "<BODY>\n";
   print "<H3>This is a test to see if Perl is Working</H3>\n";
   print "<P>\n";
   print "<H5>If you can see this, Perl is properly configured</H5>\n";
   print "</BODY>\n";
   print "</HTML>\n"; 
How to Test the Script
To test the script, browse to the Perl script in Internet Explorer. For example, if you placed the testing.pl file in a folder named cgi-bin in your root web, you would type the following in the Internet Explorer address bar: 
http://localhost/cgi-bin/testing.pl 

The third-party products discussed in this article are manufactured by vendors independent of Microsoft; we make no warranty, implied or otherwise, regarding these products' performance or reliability.


Additional query words: PWS 

Keywords : kbdta 
Version : WINDOWS:2000 
Platform : WINDOWS 
Issue type : kbinfo 
Technology : kbvcSearch 

----
You should install perl and then PWS. Use perl.exe %s %s instead 
of perlis.dll %s %s and add each entry one by one.

--------------DC100FF391645D3B0FE47D52--



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

Date: 06 Aug 2000 18:10:35 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: mod_perl weirdness.
Message-Id: <m1r981x4dw.fsf@halfdome.holdit.com>

>>>>> "noodle42" == noodle42  <noodle42@my-deja.com> writes:

noodle42> SO : I have a .htaccess file with :

noodle42> ---
noodle42> SetHandler perl-script
noodle42> PerlHandler noodle::Pictures
noodle42> PerlSendHeader On
noodle42> ---

noodle42> and in /usr/local/apache/lib/perl/noodle/Pictures.pm (file) is the
noodle42> script itself.

noodle42> The script is totally stripped down to :

noodle42> ---
noodle42> package noodle::Pictures;
noodle42> use strict;

noodle42> sub handler
noodle42> {
noodle42>         print "Content-type: text/html\n\n";
noodle42>         print "<b>Date: ", scalar localtime, "</b><br>\n";
noodle42>         return 0;
noodle42> }

First comment... lowercase package names are reserved for Perl internals,
like pragmas (strict, lib, etc.).  Please use an uppercase name.

noodle42> The problem : It works every 4th or 5th time (displaying the time) - the
noodle42> remaining times I get an "internal server error"[1] or a "Document
noodle42> contained no data" .

My bet is that many of the servers you are running pulled in a bad
version of the file at one point, so the require mechanism says "we
already have this" but the execution engine says "but it's not
defined".

Restart your server after each time you change the file, and all
should be well.  If you don't want to do that, see "Apache::StatINC"
and use that.

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Mon, 07 Aug 2000 01:27:57 GMT
From: joekind@my-deja.com
Subject: Need faster metasearch
Message-Id: <8ml3ar$3ce$1@nnrp1.deja.com>

Hi.  I made a metasearch script which searches 7 engines and I was
wondering how I could speed it up.  Should I use forking or
multithreading or something else.  I would really appreciate it if you
could supply me with some example code so I will be able to completely
understand.  Thanks in advanced.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 07 Aug 2000 02:24:46 GMT
From: "David Kocchi" <dkocchi@home.com>
Subject: Newbie needs help
Message-Id: <O5pj5.68024$ll.418466@news1.rdc1.az.home.com>

I just recently picked up Elizabeth Castro's book Perl and CGI. I having
problems getting past the first step. I am running windows 98, and I'm using
notepad to write my scripts. I also downloaded ActivePerl down to my machine
along with the other programs needed to install it. I have a few questions
maybe you can answer.

Lets see if I have the correct idea how this all works.

1. I'll open note pad and write my script.
2. Save the file as a text document with an suffix of either .cgi or .pl
3. Upload it to a unix server. I have been uploading the file to my local
community college who should
     have a Unix server. Can the file be put anywhere on the server and
still work?
4. Type in Url of file and the file should render in the browser.

What if I want to view it locally on my machine.
How do I use activeperl that I downloaded?
The thing that is confusing me is I not really sure what this program is
suppose to do.
When I'm saving my text document it is adding .txt to the end of
test.cgi.txt   Is this ok?

Here is the script from the book that I wrote.

Thanks for any help.  Dave Kocchi

Sorry for not having a clue but you have to start somewhere.


#!/usr/local/bin/perl

print "content-type:text/html\n\n";

print "Show me the monkey";





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

Date: Mon, 7 Aug 2000 12:41:41 +1000
From: "Troy Rasiah" <troyr@vicnet.net.au>
Subject: Re: Newbie needs help
Message-Id: <nnpj5.73463$N4.1962628@ozemail.com.au>

"David Kocchi" <dkocchi@home.com> wrote in message
news:O5pj5.68024$ll.418466@news1.rdc1.az.home.com...
> I just recently picked up Elizabeth Castro's book Perl and CGI. I having
> problems getting past the first step. I am running windows 98, and I'm
using
> notepad to write my scripts. I also downloaded ActivePerl down to my
machine
> along with the other programs needed to install it. I have a few questions
> maybe you can answer.
>
> Lets see if I have the correct idea how this all works.
>
> 1. I'll open note pad and write my script.
> 2. Save the file as a text document with an suffix of either .cgi or .pl
> 3. Upload it to a unix server. I have been uploading the file to my local
> community college who should
>      have a Unix server. Can the file be put anywhere on the server and
> still work?
File has to be in a cgi-executable directory. Most VWS(Virtual Web Servers)
have one assigned to them ie cgi-bin
> 4. Type in Url of file and the file should render in the browser.
>
> What if I want to view it locally on my machine.
Download a web server
Sambar Server is easy to use
http://www.sambar.com
> How do I use activeperl that I downloaded?
> The thing that is confusing me is I not really sure what this program is
> suppose to do.
> When I'm saving my text document it is adding .txt to the end of
> test.cgi.txt   Is this ok?
ACKY! get rid of the .txt

Better to use a text editor like TextPad or NoteTab Pro
or vi if you have telnet access to the local community college unix server

>
> Here is the script from the book that I wrote.
>
> Thanks for any help.  Dave Kocchi
>
> Sorry for not having a clue but you have to start somewhere.
>
>
> #!/usr/local/bin/perl

Make sure that is the correct path of your perl compiler
Type "whereis perl"
from your unix command prompt and it should give you the path
>
> print "content-type:text/html\n\n";
>
> print "Show me the monkey";
>
>
>

Troy




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

Date: Mon, 07 Aug 2000 13:36:49 +1000
From: Garry Optland <garry@pacificpower.com.au>
Subject: PerlDAP 1.4 and Perl 5.6 compile problems
Message-Id: <398E2ED1.F35912B6@pacificpower.com.au>

Hi,

I am trying to compile PerLDAP 1.4 on a Solaris 5.7 box running Perl
5.6, but get lots of errors regarding an undeclared variable as per
below. I am using gcc, and Perl 5.6 compiled and installed OK, plus
another 6 modules that I use compiled OK. The module compiles OK on a
Solaris 5.7 box running Perl 5.004. Would anybody be able to get me
started to find what is causing the problem. BTW, I am not a C
programmer.

Error messages:
API.c: In function `avref2charptrptr':
API.c:205: `na' undeclared (first use in this function)
API.c:205: (Each undeclared identifier is reported only once
API.c:205: for each function it appears in.)
API.c: In function `avref2berptrptr':
API.c:235: `na' undeclared (first use in this function)
API.c: In function `parse1mod':
API.c:377: `na' undeclared (first use in this function)
API.c: In function `XS_Mozilla__LDAP__API_ldap_compare_ext':

And lots more of the same error......

Any help really appreciated.

Regards,
    Garry Optland






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

Date: 06 Aug 2000 19:24:44 -0500
From: aperrin@demog.berkeley.edu (Andrew J. Perrin)
Subject: Re: Subroutine References
Message-Id: <878zu9sysz.fsf@achebe.perrins>

"Gabe" <grichards@flashcom.net> writes:

> I have a vairable with the name of a subroutine in it. I want to execute
> that subroutine but I keep getting an error. The camel book says it's
> because only hard referneces are allowed by use strict and symbolic
> references are disallowed. I've just begun using references so I don't
> really understand the difference or the problem. Please help.

In a nutshell, a symbolic reference is really a string containing the
name of something, as in:

$foo = 'GetEditEvent';
&$foo;

whereas a hard reference contains a literal pointer to the something:

$foo = \&GetEditEvent;
&$foo;

Hard references are preferred for several reasons, including avoiding
the danger of polluting the namespace and (I think) that they are
faster.  As you can see from the above, there is no immediate way to
'convert' between the two, although you might be able to do it with
something like:

$foo = 'GetEditEvent';
$bar = eval "\\&$foo";

perldoc perlref will give you much enlightenment.

> 
>  my $referer = $cgi->referer();
>  my $go = $1 if $referer =~ /go\=(.*)\&/;
>  &$go($sessionid, 'Record Added');
> 
> So $go contains something like GetEditEvent, and I suppose it's a symbolic
> reference. Can I convert it to a hard reference?
> 

What if someone were to send you a referer string that contains
garbage or, even worse, malicious code?  Wouldn't you rather check
what's coming in than simply allow anyone to call any subroutine as
part of the URL?  How about this:

my %dispatch = ( 'GetEditEvent' => \&GetEditEvent,
	'DoSomethingElse' => \&DoSomethingElse);
if (exists $dispatch->{$go}) {
	&{$dispatch->{$go}};
}

Andrew Perrin


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

Date: Mon, 07 Aug 2000 02:44:17 GMT
From: decklin+usenet@red-bean.com (Decklin Foster)
Subject: Re: Subroutine References
Message-Id: <5opj5.12548$f_5.64484@news1.rdc1.ct.home.com>

Gabe <grichards@flashcom.net> writes:

>  my $go = $1 if $referer =~ /go\=(.*)\&/;
>  &$go($sessionid, 'Record Added');

Ouch. Please test your code with all of the following values for
$referer:

'go=foo'                        # RE fails to match
'thiscouldbeaproblem'           # ditto, but more obvious
'go=foo&stop=bar&turn=baz'      # $1 eq 'foo&stop=bar'
'go=&'                          # $1 eq ''

And be sure to read the suggestion already given about fixing the
glaring insecurity. If you don't have -T on, add it. (Same goes for
-w, as always.)

-- 
There is no TRUTH. There is no REALITY. There is no CONSISTENCY. There
are no ABSOLUTE STATEMENTS. I'm very probably wrong. -- BSD fortune(6)


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

Date: Sun, 06 Aug 2000 22:42:49 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Syntax Question
Message-Id: <30qrossphuf2teangqqlfj7alvcmqfhngj@4ax.com>

Anno Siegel wrote:

>>What is a bit bizarre is that read()
>>returns the length of the reduced string, NOT the number of bytes read.
>>Maybe this is a bug? If you're used to both numbers being the same, it's
>>hard to appreciate the difference, let alone say which is correct.
>
>There's "correct", and there's "useful".
>
>At first glance, the more useful behavior appears to be for read() to
>return the number of bytes consumed from the file, not the length of
>the string returned, because you have the latter anyway. (Even with
>four-argument read you do, indirectly.)

Yes.

>Then again, for correctness, the count returned ought to agree with the
>length parameter given to read().

Er... you pass it a number of bytes to read from the file. It returns
the length of the string. It's not necessarily the same thing.

>So how does read() behave in cases
>where there's a difference?  In other words, if a file begins with
>"a\r\nb", what does read( FILE, $buf, 2) read?  What should it read?

It think it should try to read "a\r". When CRLF is converted into "\n",
there is no CRLF, so it remains as it is. The string it returns is a\r".

>If we count bytes in the file, we must face a situation where certain
>numbers of bytes *cannot* be read from a file (and the semantics of
>end-of-line adjustment remain valid).

I can't really see where your "correct" and "useful" say a different
thing. It looks to me like you, and me, both prefer that it returns the
number of bytes read in the file.

As I see it, there's these steps involved:

 * pass a number of bytes, for example 100, to read from a file
 * postprocess this string of 100 bytes (unless fewer were read) turning
CRLF into "\n"
 * pass that string into the second argument of read().

The description for read() in perlfunc says:

	Returns the number of bytes actually read

That says to me: the number of bytes consumed, NOT the number of bytes
returned after postprocessing. In the above example, except in a case
like EOF, it should return 100.

I think the behaviour in ActiveSate Perl is a bug.

-- 
	Bart.


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3931
**************************************


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