[8848] in Perl-Users-Digest
Perl-Users Digest, Issue: 2465 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 30 15:08:07 1998
Date: Thu, 30 Apr 98 12:00:33 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 30 Apr 1998 Volume: 8 Number: 2465
Today's topics:
.pll vs .dll in modules <brhess@email.msn.com>
Re: commenting a whole block? <rootbeer@teleport.com>
Re: Easy Question?? (John Porter)
Re: Easy Question?? <rootbeer@teleport.com>
Re: Help Beginner Modify A Little Code <rootbeer@teleport.com>
Re: how quickly can you unpack your shorts ?! <dcameron@nospam.bcs.org.uk>
How to add information at the top/beginning of a file. (Dico Reyers)
Re: How to add information at the top/beginning of a fi <brianm@kodak.com>
Re: How to add information at the top/beginning of a fi <rootbeer@teleport.com>
Re: How to read command line literally? <Russell_Schulz@locutus.ofB.ORG>
How to stuff control character into a variable <shtil@netcom.com>
Re: How to stuff control character into a variable (John Porter)
Re: How to stuff control character into a variable <rootbeer@teleport.com>
Re: HTTP Proxy (Re: HTTP Request Headers) (brian d foy)
Re: HTTP Proxy (Re: HTTP Request Headers) (I R A Aggie)
Re: http Reg Exp (Earl Hood)
Re: http Reg Exp (Earl Hood)
Re: HTTP Request Headers <flavell@mail.cern.ch>
Re: HTTP Request Headers (brian d foy)
Huge array/Win32::NetAdmin::GetUsers <jfelso@att.com>
inline replace <mehta@mama.indstate.edu>
Re: inserting characters <brianm@kodak.com>
Re: inserting characters <rootbeer@teleport.com>
Listbox in pTk... Help? (Wayne C. McCullough)
Re: Newbie: How do you compile a script in Perl for Win <rootbeer@teleport.com>
Passing type AV * ? <siddiqi-kaleem@cs.yale.edu>
perl -e filenamewith_regex datafiles question <mehta@mama.indstate.edu>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 30 Apr 1998 14:18:47 -0400
From: "Bill Hess" <brhess@email.msn.com>
Subject: .pll vs .dll in modules
Message-Id: <OAFRaVGd9GA.340@upnetnews03>
What is the difference between .pll and .dll libraries in a Perl module???
Also,
If a module has a .dll does it need to have a .lib file as well?
Bill Hess
brhess@msn.com
------------------------------
Date: Thu, 30 Apr 1998 17:57:56 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Francesc Guasch <frankie@etsetb.upc.es>
Subject: Re: commenting a whole block?
Message-Id: <Pine.GSO.3.96.980430105704.8307H-100000@user2.teleport.com>
On Thu, 30 Apr 1998, Francesc Guasch wrote:
> It runs out of topic but I'm unable to do a thing with emacs with perl
> as I did with other languages, I want to indent a whole file, CTRL-i
> just indents one line.
> please tell me how ?
You're right, it's off-topic. People in a newsgroup about emacs may be
able to help you, if you can't find the answers in the docs or online
help. Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 30 Apr 1998 18:33:31 GMT
From: jdporter@min.net (John Porter)
Subject: Re: Easy Question??
Message-Id: <MPG.fb28f5bf1576378989685@news.min.net>
On Thu, 30 Apr 1998 10:59:24 -0600,
in article <3548ADEC.2020B0C6@mail.cyber-west.com>,
nic@mail.cyber-west.com (Madness) wrote:
> I am writing a flatfile database program to let users find results to
> motocross races based on class and race.
I'm kinda surprised you can get away with that in the U.S.
>...
> I am now going to print $ww2.
I've no doubt that what you want to do is trivially easy in perl,
but your description is pretty confusing. Could you post the
code that you have so far (or just email it to me), and we'll
see what's really going on.
> It seems that cgi-lib.pl would do this using the $in{'race'}, but I
> haven't had any luck with CGI.pm yet.
This has nothing to do with luck. CGI.pm is hugely superior, and is
not difficult to use. Read the docs, try the examples, post your
code if you have difficulties. (And please, when you post code,
try to trim it down to the fewest lines that demonstrate your
problem.)
Thanks.
John Porter
------------------------------
Date: Thu, 30 Apr 1998 18:57:13 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Madness <nic@mail.cyber-west.com>
Subject: Re: Easy Question??
Message-Id: <Pine.GSO.3.96.980430115255.8307T-100000@user2.teleport.com>
On Thu, 30 Apr 1998, Madness wrote:
> Subject: Easy Question??
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> I am writing a flatfile database program to let users find results to
> motocross races based on class and race.
Don't you know that class and race are irrelevant? Oh, wait... :-)
> The line that reads in the data looks like this:
> ($clsid, $class, $name, $number, $ww1, $ww2, .....$ww16) = split
> (/,/,$_,20);
> $ww1 is (Wild West Race #1, etc.)
Rather than using variable names like $ww13, why not make an array?
($clsid, $class, $name, $number, @ww) = split /,/; # maybe?
Now you can access any item by number. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 30 Apr 1998 18:19:57 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Frank Blanchard <sendto_fb@whitaker.org>
Subject: Re: Help Beginner Modify A Little Code
Message-Id: <Pine.GSO.3.96.980430111623.8307N-100000@user2.teleport.com>
On Thu, 30 Apr 1998, Frank Blanchard wrote:
> Subject: Help Beginner Modify A Little Code
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> the script returns data from a pipe delimited ascii database. the
> results print as a table row. i want to change the results to a vertical
> list. any suggestions?
> $search_results .= "<TR>";
> $hit_counter = "1";
> foreach $field (@row)
> {
> $search_results .= "<TD>$field</TD>";
> }
> $search_results .= "</TR>";
> }
First, you should indent your code consistently. Although Perl doesn't
mind how your code is laid out, it's easier for human beings to see what
matches up with what - including, in this case, the place where you've got
an extra curly brace.
Second, it looks as if you're getting a table row by putting in HTML codes
that create one. Have you tried putting in HTML codes to do something
else? If you're not sure which codes to use or where to place them, the
people in a newsgroup about HTML should be of some assistance.
Have fun with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 30 Apr 1998 18:04:48 GMT
From: "Duncan Cameron" <dcameron@nospam.bcs.org.uk>
Subject: Re: how quickly can you unpack your shorts ?!
Message-Id: <01bd7462$20b21280$553263c3@dns.btinternet.com>
Not sure that I understand your algorithm. The subject suggests something
to do with short integers but they are, usually, 2 bytes. Your algorithm
is processing single bytes. Is it:
for each byte in the 5000-byte buffer
convert to the decimal equivalent
add result into @array
end
do something with @array
If so ,then Christian's suggestion is an improvement. Also, it appears
that @array is cleared for each iteration of the loop. So, as unpack
returns an array, the push is unnecessary.
Try
@array = unpack ("C" x 5000, $buffer);
Also, in other languages/environments having large buffers and as a power
of 2 will improve performance. Try having a buffer of 16kbyte and see if
that helps.
HTH
Duncan Cameron
Christian Wetzel <cnwetzel@linguistik.uni-erlangen.de> wrote in article
<354873B6.516C@linguistik.uni-erlangen.de>...
> Lion wrote:
> >
> > I'm trying to speed up some code that processes a large (50MB) binary
file:
>
> > push (@array, map (hex($_), unpack (("H2" x 5000), $buffer)));
>
> Shouldn't do the following the same, but without the extra
> map/hex loop?
>
> push (@array, unpack ("C" x 5000, $buffer));
>
> Or am I misunderstanding the pack/unpack templates?
>
> Christian
>
------------------------------
Date: Thu, 30 Apr 1998 17:42:52 GMT
From: dico@peionline.com (Dico Reyers)
Subject: How to add information at the top/beginning of a file.
Message-Id: <3548b74e.15875715@news1.pei.sympatico.ca>
Hi There,
I am wondering how I add information at the beginning of a file. For
example, When a person submits their email address from a web page, a
perl script adds their email address to a file (which contains a list
of email addresses, each line with their own address), however it adds
it to the bottom of the list. How do I get it to bump down the
previous entries so that the latest entry is listed first?
Thanks in advance,
-Dico
------------------------------
Date: Thu, 30 Apr 1998 13:58:39 -0400
From: Brian Mathis <brianm@kodak.com>
To: Dico Reyers <dico@peionline.com>
Subject: Re: How to add information at the top/beginning of a file.
Message-Id: <3548BBCF.6674F708@kodak.com>
Dico Reyers wrote:
>
> Hi There,
>
> I am wondering how I add information at the beginning of a file. For
> example, When a person submits their email address from a web page, a
> perl script adds their email address to a file (which contains a list
> of email addresses, each line with their own address), however it adds
> it to the bottom of the list. How do I get it to bump down the
> previous entries so that the latest entry is listed first?
>
> Thanks in advance,
>
> -Dico
There is no simple function to do this. You need to create a new file
for it, print out the data you want on the top, then print the rest of
the file. Here's a general flow of what you have to do:
Get the new information
Open a temporary file
print the new info into this temp file
open the old data file
print the data from the old file to the new one
close old data file
close temp file
rename temp file to same name as old data file.
Of course, that's not the only way to do it. You could also slurp the
whole data file in as a list, then push the new data onto that list,
then write it out again, but it will all depend on how much memory you
want to use, how big you expect the data file to be, etc..
Brian Mathis
------------------------------
Date: Thu, 30 Apr 1998 18:43:06 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Dico Reyers <dico@peionline.com>
Subject: Re: How to add information at the top/beginning of a file.
Message-Id: <Pine.GSO.3.96.980430114242.8307Q-100000@user2.teleport.com>
On Thu, 30 Apr 1998, Dico Reyers wrote:
> I am wondering how I add information at the beginning of a file.
The FAQ has this information. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 30 Apr 1998 16:33:11 +0100
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: How to read command line literally?
Message-Id: <19980430.163311.6q3.rnr.w164w@locutus.ofB.ORG>
how is this about perl? redirected.
ilya@math.ohio-state.edu (Ilya Zakharevich) writes this and much more:
> If a program wants globbing of the command line, it may just do
>
> main(int argc, char *argv[], char *env[])
> {
> glob_wildcards(&argc,&argv);
> ...
> }
>
> find . -name *.blah
> or
> unzip foo *.c
not to mention `mv *.c *.c.bak'
> Command line is the most important element of IPC, and the fact that
> it is unreachable is one of the few stupidities of the *nixish
> paradigm.
long ago, I proposed a new environment variable, e.g.,
ORIGINAL_COMMAND_LINE; using it allows multiple benefits:
1. any of the few programs that want it can find it
(how many font programs use -*-*-*-*-Roman-*-*-12-*-*- ?)
2. any existing program need never know it changed
it would be a few lines added to any shell.
(I also gave the reasons why `set noglob' wasn insufficient in general.)
--
Russell_Schulz@locutus.ofB.ORG Shad 86c
------------------------------
Date: Thu, 30 Apr 1998 18:04:22 GMT
From: Yuri Shtil <shtil@netcom.com>
Subject: How to stuff control character into a variable
Message-Id: <shtilEs8nJA.Jz4@netcom.com>
Let's assume:
$a = 'F';
I want $b assigned to the equivalent of
$b = "\xF", not directly but through $a, something like:
$b = "\x$a".
I tried a lot of things but nothing worked. The most I could get is
to assign $b to F, not "\xF".
I ended up using an array @arr = ("\x0", "\x1", ..., "\xFF")
and indexing it by $a. It is ugly.
Please help.
Yuri Shtil.
------------------------------
Date: Thu, 30 Apr 1998 18:41:13 GMT
From: jdporter@min.net (John Porter)
Subject: Re: How to stuff control character into a variable
Message-Id: <MPG.fb29162a2121dc5989686@news.min.net>
On Thu, 30 Apr 1998 18:04:22 GMT,
in article <shtilEs8nJA.Jz4@netcom.com>,
shtil@netcom.com (Yuri Shtil) wrote:
>
> I want $b assigned to the equivalent of
> $b = "\xF", not directly but through $a, something like:
> $b = "\x$a".
>[etc.]
$a = 'F';
$b = chr(hex($a));
# $b is now ascii character 0x0F (017 octal)
hth,
John Porter
------------------------------
Date: Thu, 30 Apr 1998 18:52:29 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Yuri Shtil <shtil@netcom.com>
Subject: Re: How to stuff control character into a variable
Message-Id: <Pine.GSO.3.96.980430114518.8307S-100000@user2.teleport.com>
On Thu, 30 Apr 1998, Yuri Shtil wrote:
> $a = 'F';
>
> I want $b assigned to the equivalent of
>
> $b = "\xF", not directly but through $a, something like:
>
> $b = "\x$a".
In other words, if $a contains a normal character, you want $b to have the
corresponding control character? You could do this with ord and chr, or
maybe this.
($b = "$a") &= "\x1f";
The quotes around $a may actually be needed, if you might have wrong data
in $a, but they're harmless otherwise. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 30 Apr 1998 13:19:25 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: HTTP Proxy (Re: HTTP Request Headers)
Message-Id: <comdog-ya02408000R3004981319250001@news.panix.com>
Keywords: from just another new york perl hacker
In article <MPG.fb273275033922f989682@news.min.net>, jdporter@min.net (John Porter) posted:
>So, can anyone supply a pointer to a proxy server written in perl?
>It must not be hard to do, what with all the great support modules
>available... but there doesn't seem to bee a "cookbook" way
>mentioned in the module docs.
see my post in the original thread. basically, go over to Randal's
WebTechnique column [1] that shows how to make a proxy server using the
HTTPD::Daemon module.
[1] <URL:http://www.stonehenge.com/merlyn/WebTechniques/>
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>
------------------------------
Date: Thu, 30 Apr 1998 14:05:57 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: HTTP Proxy (Re: HTTP Request Headers)
Message-Id: <fl_aggie-3004981405580001@aggie.coaps.fsu.edu>
In article <MPG.fb273275033922f989682@news.min.net>, jdporter@min.net
(John Porter) wrote:
+ On Thu, 30 Apr 1998 15:34:49 GMT, in article
+ <3548996d.16209265@news.digex.net>, webmaster@gardenweb.com wrote:
+ > Does anyone know of a script or a site that might be able to show me
+ > exactly what Netscape sent the server?
+ Sounds like you want a simple proxy server.
+ So, can anyone supply a pointer to a proxy server written in perl?
Yep. Go look in Randal's WebTechniques column
<url:http://www.stonehenge.com/~merlyn/WebTechniques/>. You'll want
Column #11. Its an anon proxy server.
It works pretty well, too. But oddly enough, it causes some password
challenges to fail. Not certain why, and not particularly concerned.
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>
------------------------------
Date: 30 Apr 1998 17:05:26 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: http Reg Exp
Message-Id: <6iab0m$hl5@news.service.uci.edu>
In article <893893462.449299@cabal>,
? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au> wrote:
>>URL1: http://myserver.com/dir/file.
>>URL2: http://myserver.com/dir/file
>
>These are not URLs. urls start with <URL: and end with a >
Not quite. The "<URL: ...>" construct is the recommended way (by the
RFC) to list URLs in a text document to clearly deliminate it from
surrounding text to avoid ambiguities (for URL detecting code). It
also allows spaces/newlines to break long URLs for readable. In sum,
"<URL: ...>" is a stylistic construct like titles of cited books should
be capitialized.
Now, the reason most software does not fully support <URL:...>, when
converting to HTML, is that most people do not use it, and users still
expect to have a URL in text hyperlinked. Hence, filter code is
written to try to detect URLs anywhere.
If proper <URL:...> were to be done (ie. urls broken over multiple
lines) along with general detection, it would complicate the filtering
code. If using Perl, you would have to slurp the entire file into
memory instead of doing the more memory efficient line-by-line filtering.
I believe the following sample program will convert text data to HTML,
hyperlinking URLs (using recommended style and free-form style) and
escaping special characters:
#!/usr/local/bin/perl
########################################################################
## Perl program to convert plain text to HTML with URL detection.
## by ehood@medusa.acs.uci.edu
########################################################################
## Define regex for URLs mixed in with text.
$Url = '(?:http://|https://|ftp://|afs://|wais://|telnet://|ldap://' .
'|gopher://|news:|nntp:|mid:|cid:|mailto:|prospero:)';
$UrlExp = $Url . q%[^\s\(\)\|<>"']*[^\.;,"'\|\[\]\(\)\s<>]%;
## Routine to hyperlink a URL (used in s/// below)
sub link_url {
my $str = shift;
my $url = $str;
if ($url =~ s/^<URL://i) {
chop $url;
$url =~ tr/ \t\n\r//d;
}
qq|<A HREF="$url">|.htmlize($str).qq|</A>|;
}
## Routine to escape special chars
sub htmlize {
my $str = shift;
$str =~ s/&/&/g;
$str =~ s/</</g;
$str;
}
## MAIN block
MAIN: {
$/ = undef;
$text = <>;
$text =~ s@(<URL:[^>]+>|$UrlExp|&|<)
@length($1) == 1 ? htmlize($1) : link_url($1)
@geiox;
print "<PRE>\n", $text, "</PRE>\n";
exit 0;
}
__END__
I'd be interested if anyone wants to benchmark this against simplier
code. I figure the regex used (<URL:[^>]+>|$UrlExp|&|<) may not be
very fast due to the alternation. But it is simplest way to deal with
URLs and special characters w/o tokening the data.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: 30 Apr 1998 18:26:30 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: http Reg Exp
Message-Id: <6iafom$k1t@news.service.uci.edu>
In article <6i3598$ec7$1@comdyn.comdyn.com.au>,
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
>My site list, to be parsed:
>
>http://www.perl.com/: Perl stuff
>http://www.perlie.com:8080/: More perl stuff
>http://www.perl.com/, http://www.perlie.com/cgi/aa?a=b,d,s
>http://www.perl.com/.
>
>How do you parse the above?
See the program I posted in another post. Note, it does allow ':' to
be at the end of a URL. So, you just need to add a colon to the last
character class in $UrlExp in the program to count it as a terminating
character.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: Thu, 30 Apr 1998 17:48:34 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: HTTP Request Headers
Message-Id: <Pine.A41.3.95a.980430174133.142072E-100000@rsplus02.cern.ch>
On Thu, 30 Apr 1998, Spike Hernandez wrote:
> I need to see the request headers for an HTTP request EXACTLY as the
> browser sends them. It is a little beyond my ken to make a faux server
> that can record them.
I feel sure that Nick Kew's CGI FAQ addresses this requirement.
What's more, I see it's exactly where it ought to be on the FAQ
hierarchy, if you can't find it on the c.i.w.authoring.cgi group at your
friendly news server. Well done Nick.
Here's the magic words I think you're looking for:
| I'm having trouble with my headers. What can I do?
--
------------------------------
Date: Thu, 30 Apr 1998 13:11:53 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: HTTP Request Headers
Message-Id: <comdog-ya02408000R3004981311530001@news.panix.com>
Keywords: from just another new york perl hacker
In article <3548996d.16209265@news.digex.net>, webmaster@gardenweb.com posted:
>I need to see the request headers for an HTTP request EXACTLY as the
>browser sends them. It is a little beyond my ken to make a faux server
>that can record them.
it's not beyond you to make a server! there's an HTTP::Daemon module
out there that makes the thing a peice of cake. Randal has even
demonstrated it in a couple of WebTechnique columns
<URL:http://www.stonehenge.com/merlyn/WebTechniques/>.
here's a short server i wrote a long time ago when i was messing with
HTTPeek. it simply spits back a lot of info about the request and server
thingys. you'll have to change some of the hard-coded paths and such
to play with it. or, try <URL:http://computerdog.com:8088/>, but the
admins tend to kill it though since they don't know what it is.
good luck :)
dog[3] more httpd.pl
#!/usr/bin/perl -wT
$debug = 0;
use strict;
use vars qw($debug);
use subs qw(you_go_girl test log_connection);
use Socket;
use HTTP::Date;
##########################################################################
# which port do we want to use?
#
my $port = '8088';
##########################################################################
# set up the socket stuff
#
my $prototype = getprotobyname('tcp');
socket(SOCKET, PF_INET, SOCK_STREAM, $prototype);
setsockopt(SOCKET, SOL_SOCKET, SO_REUSEADDR, 1);
bind SOCKET, sockaddr_in($port, INADDR_ANY) or die "bind: $!\n";
listen SOCKET, SOMAXCONN or die "listen: $!\n";
##########################################################################
# redirect STDERR to a log file
#
open LOG, ">> /opt/opt3/home4/computerdog/httpd/logs/httpd.log"
or die "log: $!\n";
select LOG;
$| = 1;
open STDERR, ">&LOG" or die "dup STDERR: $!\n";
my $date = HTTP::Date::time2str(time);
print LOG "[$date] starting up on port $port\n";
print STDOUT "Starting up... port $port\n";
##########################################################################
# go 'round and 'round until we get really dizzy
#
while( "i lay dying" )
{
my $p_address = accept(REQUEST, SOCKET);
my ($port, $address) = sockaddr_in( $p_address );
my $host_name = gethostbyaddr( $address, AF_INET );
my $time = HTTP::Date::time2str(time);
log_connection($host_name, $time);
select REQUEST; $| = 1;
print STDOUT "socket loop:calling you_go_girl\n" if $debug > 0;
you_go_girl;
close REQUEST;
}
##########################################################################
# the main request handler
#
sub you_go_girl
{
my $request = <REQUEST>;
print STDOUT "you go girl: reading request\n" if $debug > 0;
while (defined($_ = <REQUEST>))
{
$request .= $_;
last if m/^(?:\r|\n)+$/;
}
print STDOUT "you go girl: sending request\n" if $debug > 0;
print REQUEST <<"HTTP";
HTTP/1.0 200 Data like ducks in a row
Content-type: text/plain
my PID: $$
my UID: $<
my eUID: $>
HTTP Request
------------
$request
HTTP
return 1;
}
##########################################################################
# remember who connects to us
#
sub log_connection
{
my ($host, $time) = @_;
print LOG "[$time] connection from $host\n";
return;
}
sub test
{
}
__END__
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>
------------------------------
Date: Thu, 30 Apr 1998 13:41:27 -0400
From: "John Felso" <jfelso@att.com>
Subject: Huge array/Win32::NetAdmin::GetUsers
Message-Id: <6iad4m$r45@newsb.netnews.att.com>
Does anyone have experience handling really really large arrays? I need to
use the Win32::NetAdmin::GetUsers command to get a list of users on a large
domain. Unfortunately their is not way to retrieve one user at a time (as
far as I know anyway). Since the GetUsers routine fills an array with all
users at once, my script fails with an "Out of memory!" message. Here is the
code:
require "NT.ph";
use Win32::NetAdmin;
Win32::NetAdmin::GetDomainController('', 'DOMAIN', $dc) || die;
print "$dc\n";
Win32::NetAdmin::GetUsers($dc,&FILTER_NORMAL_ACCOUNT,\@userArray) || die;
foreach $user (@userArray) {
print "$user\n";
}
I thought that tieing the array might help, but that doesn't seem to be
implemented on NT. I'm not sure if that would help anyway.
John Felso
jfelso@att.com
------------------------------
Date: Thu, 30 Apr 1998 11:56:36 -0500
From: Miten S Mehta <mehta@mama.indstate.edu>
To: Mark-Jason Dominus <mjd@op.net>
Subject: inline replace
Message-Id: <Pine.LNX.3.96.980430115512.13234A-100000@mama.indstate.edu>
4/30/98
Hello,
I am unable to get the perl command
perl -pi.bak -e programfile.pl datafile
to do inline replace. could you guide?
------------------------------
Date: Thu, 30 Apr 1998 14:01:21 -0400
From: Brian Mathis <brianm@kodak.com>
To: Jeff McCreary <jeffmcc@mindspring.com>
Subject: Re: inserting characters
Message-Id: <3548BC71.BE4889A0@kodak.com>
Jeff McCreary wrote:
>
> Is there a way to insert a "/" into the middle of a string without
> trying to concantenate substrings?
Well, there is no atomic function to accomplish this, but concatenation
is very simple, ulness there is some specific reason you can't do it.
Depending on what your string looks like, you need to either split() or
substr() to break it apart, then you can join('/', @data); to put it
all together.
Brian Mathis
------------------------------
Date: Thu, 30 Apr 1998 18:10:15 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Jeff McCreary <jeffmcc@mindspring.com>
Subject: Re: inserting characters
Message-Id: <Pine.GSO.3.96.980430110445.8307K-100000@user2.teleport.com>
On Thu, 30 Apr 1998, Jeff McCreary wrote:
> Is there a way to insert a "/" into the middle of a string without
> trying to concantenate substrings?
Yes, there are several. Here's one:
my $string = "hello world!";
substr($string, length($string)/2, 0) = '/';
Of course, your request is ambiguous if the string has an odd number of
characters, but you can easily fix this technique to deal with that. If
this isn't exactly what you want, other methods can be created with the
operations documented in perlfunc and perlop. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 30 Apr 1998 17:33:21 GMT
From: wayne@Glue.umd.edu (Wayne C. McCullough)
Subject: Listbox in pTk... Help?
Message-Id: <6iacl1$r34$1@hecate.umd.edu>
I am having no small amount of trouble with the Listbox widget with
perl Tk.
Lately I have been playing around with the Selection aspect of
the Listbox. I would like to simulate a large array of radiobuttons
with the Listbox widget. I have tried bind'ing to button operations
on the listbox, but it doesn't seem to override the default listbox
selection behaivor.
1) How does one override the default selection behavior (I want to
toggle the selection on a <B1-Button> event.).
2) How does the Selection normally behaive? I have not figured out
how to get more than one thing slected.
3) Where is some in depth documentation on this subject?
Wayne McCullough
------------------------------
Date: Thu, 30 Apr 1998 18:04:33 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Jonathan Burns <JonathanBurns@onlineinfoservices.com>
Subject: Re: Newbie: How do you compile a script in Perl for Win32?????
Message-Id: <Pine.GSO.3.96.980430110247.8307J-100000@user2.teleport.com>
On Thu, 30 Apr 1998, Jonathan Burns wrote:
> I have a .pl file, but when I access it from the web, it displays the
> script as if it were a text file.
It sounds as if you want your server to run the script. Ask your webmaster
how to make that happen. Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 30 Apr 1998 13:02:23 -0400
From: Kaleem Siddiqi <siddiqi-kaleem@cs.yale.edu>
Subject: Passing type AV * ?
Message-Id: <3548AE9F.41C67EA6@cs.yale.edu>
I'd like to pass a pointer to the first element
in a Perl array to a C subroutine, so that it
can be modified. Can anyone help me with the perl syntax?
My XS subroutine is:
void
SetArrayValue(array, width, height, val)
AV *array
int width
int height
SV *val
CODE:
{
int xx,yy;
for(yy = 0; yy < height; yy++){
for(xx = 0; xx < width; xx++){
av_store(array,xx+yy*height,val);
}
}
}
OUTPUT:
array
Consider a perl array, called @array,
that contains 100x100 floating point numbers.
The perl code:
$var = 51.5;
SetArrayValue(\@imagearray,100,100,$var);
complains that the first argument is not of type AVPtr
(although passing a pointer to a scalar works).
Can anyone enlighten me?
-----------------------------------------------------------------------
Kaleem Siddiqi Dept. of Computer Science
siddiqi-kaleem@cs.yale.edu Yale University
Phone: (203) 432-4713 P.O. Box 208285, Yale Station
FAX: (203) 432-0593 New Haven, CT 06520-8285
http://www.cs.yale.edu/users/siddiqi-kaleem/
-----------------------------------------------------------------------
------------------------------
Date: Thu, 30 Apr 1998 10:42:15 -0500
From: Miten S Mehta <mehta@mama.indstate.edu>
To: Tom Christiansen <tchrist@mox.perl.com>
Subject: perl -e filenamewith_regex datafiles question
Message-Id: <Pine.LNX.3.96.980430103928.8184A-100000@mama.indstate.edu>
4/30/98
Hello,
I have put a bunch of regex in a file to operate on input file and this
does not work.
perl -pi.bak -e regex_file.pl datafile
could you guide?
I tried regex file with both #!....and without it and also the name in
single quotes, double qoutes and without quotes.
Thank you.
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 2465
**************************************