[13675] in Perl-Users-Digest
Perl-Users Digest, Issue: 1085 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 15 17:05:51 1999
Date: Fri, 15 Oct 1999 14:05:32 -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: <940021531-v9-i1085@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 15 Oct 1999 Volume: 9 Number: 1085
Today's topics:
Re: "Proper" way to load a file <rhomberg@ife.ee.ethz.ch>
Re: "Proper" way to load a file <jeff@vpservices.com>
Re: "Proper" way to load a file (Craig Berry)
Re: "Proper" way to load a file (Abigail)
"Protecting" Perl source code <webmaster@webdream.com>
Re: @ARGV ---- Arrrrgggghhhh! :-) <ltl@rgsun5.viasystems.com>
Re: @ARGV ---- Arrrrgggghhhh! :-) <rhomberg@ife.ee.ethz.ch>
Re: @ARGV ---- Arrrrgggghhhh! :-) (Jack Applin)
Re: @ARGV ---- Arrrrgggghhhh! :-) (Abigail)
Alternatives to Net::Telnet jasonnardone@my-deja.com
Re: Alternatives to Net::Telnet <newsposter@cthulhu.demon.nl>
Re: Basic Domain name lookup <agent@gte.net>
Re: Basic Domain name lookup <mamster@mamster.net>
Re: Can a perl script output image? (Michel Dalle)
Re: Can a perl script output image? (Clinton Pierce)
Re: Can a perl script output image? <sjohns17@uic.edu>
Re: Can a perl script output image? marias@total.net
Re: CGI Perl <marcel.grunauer@lovely.net>
Chat room scalability - on linux (apache) <SteveK@nyaaa.demon.co.uk>
CLUELESS =( (Max)
Re: CLUELESS =( <webmaster@webdream.com>
Re: DBD DELETE statement <newsposter@cthulhu.demon.nl>
File Locking in Win32 PerlScript. epan@my-deja.com
getting variables embeded in string to be evaluated (Bill)
good salt for crypt() ? <dtbaker_@busprod.com>
Grabbing image size? fharris@xmission.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 15 Oct 1999 21:10:19 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: "Proper" way to load a file
Message-Id: <38077C1B.805B57@ife.ee.ethz.ch>
Paul D wrote:
>
> I'm a bit fresh to Perl myself, so others will correct me if I'm wrong.
>
> open (FILE, "<$File") || die("I just can't do it cap'n! $!");
> while(<FILE>)
> {contents = $contents . $_ ;}
> close (FILE);
Paul, I ask you to follow some standards on this newsgroup:
- do not quote jeopardy style
- test your code. It does not compile, there is a $ missing on the third
line
s/(?<!\$)\bcontent/\$content/;
> If you want a space between each line as well,
> just
> change the one line above into this:
>
> {contents = $contents . " " . $_ ;}
If you test that code (after correction), you'll see that it adds a
space in front of every line. I would not exactly call that "adding a
space between each line"
And there is of course the correct solution with undef $/ mentioned by
some people:
printf "hallo\npeter\n" | perl -e'$_=do{local $/;<>}; print'
- Alex
------------------------------
Date: 15 Oct 1999 18:24:25 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: "Proper" way to load a file
Message-Id: <38077106.4C69F4CF@vpservices.com>
Paul D wrote:
>
> I'm a bit fresh to Perl myself, so others will correct me if I'm wrong.
>
> open (FILE, "<$File") || die("I just can't do it cap'n! $!");
> while(<FILE>)
> {contents = $contents . $_ ;}
> close (FILE);
Ok, you're wrong, I'll correct you. This code you sent *does* work
(after correcting a couple of typos), it puts the contents of a file
into a string. But it works in a bad way. Here's some more code that
does the same thing but in an even worse way:
#-- warning don't try this at home--
my $contents='';
open(FH,"<$file") || die "Can't open $file: $!";
while(<FH>){
my @ary = split //;
for(@ary) { $contents .= $_; }
}
close(FH) || die "Can't close $file: $!";
And here's some more code (the correct code), based on postings by Craig
Berry and others, that does the right thing:
open(FH,"<$file") || die "Can't open $file: $!";
my $contents = do { local $/; <FH>; };
close(FH) || die "Can't close $file: $!";
Ok, so my facetious snippet above is very bad and yours is bad, and what
Craig Berry and others have posted is not bad. Here's why:
a) Your code takes longer to TYPE than Craig's and mine takes even
longer than yours. Craig's is shortest so it is best for lazy people.
b) Your code takes longer to RUN since it perfoms many more operations
per file than Craig's and mine takes even longer than yours. Let's say
the file we are reading is 10 lines of 10 characters each. My code goes
through the file one character at a time and performs a concatenation
operation for each character (100 operations); yours is slightly
better, it goes through one line at a time and performs one
concatentation operation for each line (10 operations); and Craig's is
much better than either since it gets the whole file at once and
performs *no* concatenation operations (0 operations). Craig's is most
effecient so it is best for lazy computers.
Capeche?
--
Jeff
------------------------------
Date: Fri, 15 Oct 1999 20:18:09 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: "Proper" way to load a file
Message-Id: <s0f301odr0150@corp.supernews.com>
Alex Rhomberg (rhomberg@ife.ee.ethz.ch) wrote:
: Paul D wrote:
: > open (FILE, "<$File") || die("I just can't do it cap'n! $!");
: > while(<FILE>)
: > {contents = $contents . $_ ;}
: > close (FILE);
:
: - test your code. It does not compile, there is a $ missing on the third
: line
: s/(?<!\$)\bcontent/\$content/;
No need for that there newfangled look-behind. A simple
s/contents/\$contents/ will get the first one. :)
: > If you want a space between each line as well, just
: > change the one line above into this:
: >
: > {contents = $contents . " " . $_ ;}
This time *you* left off the $. And better yet would be
{ $contents .= $_; }
or
{ $contents .= " $_"; }
or
{ $contents .= ' ' . $_; }
according to taste.
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "They do not preach that their God will rouse them
a little before the nuts work loose." - Kipling
------------------------------
Date: 15 Oct 1999 15:54:42 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: "Proper" way to load a file
Message-Id: <slrn80f540.q8s.abigail@alexandra.delanet.com>
Paul D (pdobbs@home.com) wrote on MMCCXXXVI September MCMXCIII in
<URL:news:38072314.EA6AF51F@home.com>:
;; I'm a bit fresh to Perl myself, so others will correct me if I'm wrong.
;;
;; open (FILE, "<$File") || die("I just can't do it cap'n! $!");
;; while(<FILE>)
;; {contents = $contents . $_ ;}
;; close (FILE);
Urg.
open FILE, $file or die "Cannot open $file: $!\n";
my $contents = do {local $/; <FILE>};
close FILE;
;; file into one variable. If you want a space between each line as well,
;; just
;; change the one line above into this:
;;
;; {contents = $contents . " " . $_ ;}
open FILE, $file or die "Cannot open $file: $!\n";
my $contents = join " " => <FILE>;
close FILE;
But that would be silly, why would you want everyone line, except the
first, start with a space? If you want to *replace* newlines with
spaces, there are a few options. One is:
open FILE, $file or die "Cannot open $file: $!\n";
chomp (my @contents = <FILE>);
my $contents = join " " => @contents;
close FILE;
;; So the idea is that it says "While reading input from filehandle FILE,
;; add the stuff from the default storage variable $_ onto the end of the
;; $contents variable. (and place a space inbetween if you want that too)
;; I don't know that there is anything bad about your format though. I like
;; the above though for just doing a simple "total" read-in of a file.
I like proper use of $/.
Abigail
--
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
${qq$\x5F$} = q 97265646f9 and s g..g;
qq e\x63\x68\x72\x20\x30\x78$&eggee;
{eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Fri, 15 Oct 1999 18:43:17 GMT
From: "Craig Vincent" <webmaster@webdream.com>
Subject: "Protecting" Perl source code
Message-Id: <9BKN3.252$cF.192@198.235.216.4>
I'm looking at distributing various commercial perl scripts I've developed.
Obviously once I start distributing it more than likely it will be passed
around in the underworld webmaster market (assuming people like what I've
done :D).
My question to you gurus is this:
Do you have any ideas or suggestions for protection features I could
put into place to help minimize the damage done by people pirating my
scripts?
Obviously if the script falls into the hands of someone who knows a decent
amount
of perl no amount of security I place will stop he/she from usurping the
services of my scripts
however if I can at least protect myself against those who know little or no
perl it would
be very beneficial.
Sincerely,
Craig Vincent
------------------------------
Date: 15 Oct 1999 17:43:34 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: Re: @ARGV ---- Arrrrgggghhhh! :-)
Message-Id: <7u7p46$mgp$1@rguxd.viasystems.com>
Tom Turton <tturton@ntx.waymark.net> wrote:
:>Obviously, I've never fully comprehended how @ARGV handled command line
:>inputs...but I've just now tripped over something that I can't seem to
:>find the answer to in my books, or by doing searches on the Perl pod on
:>my system.
:>I "want" to feed wildcard character filenames in via @ARGV, but it is
:>seeking out matches and passing matched filenames in @ARGV. Is there
:>any way to override this feature short of having to put quotes around my
:>command line input?
Well, technically, this is not a Perl problem. It is your shell that
is expanding the filename matching characters in your argument list
before handing the arguments to your application. Why do you not want
to quote those arguments? That is the easiest way to deal with it.
Depending on your shell, you may also be able to turn off globbing.
If quoting the arguments is really something that you can't or don't
want to do for some reason, read the manual page for your shell and
see if there is a facility for turning off globbing (aka "filename
substitution" and "filename expansion").
--
// Lee.Lindley /// I used to think that being right was everything.
// @bigfoot.com /// Then I matured into the realization that getting
//////////////////// along was more important. Except on usenet.
------------------------------
Date: Fri, 15 Oct 1999 20:53:18 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
To: Tom Turton <tturton@ntx.waymark.net>
Subject: Re: @ARGV ---- Arrrrgggghhhh! :-)
Message-Id: <3807781E.A40FEE07@ife.ee.ethz.ch>
Tom Turton wrote:
> have files:
> abc1.xxx abc2.xxx abc3.xxx abc4.xxx abc5.xxx
>
> want to make call to Perl script, move_em.pl:
>
> move_em.pl abc*.xxx def*.xxx
>
> My intention was to grab the strings "abc*.xxx" and "def*.xxx" from
> @ARGV, but instead, @ARGV contains "abc1.xxx" "abc2.xxx" ....
>
> Thanks (and feel free to flame if I've completely overlooked something
> which is intuitively obvious to the most semi-casual observer ;-)
The obvious stuff is that the *shell* does this for you. To help all
those scripts out, so they don't have to do wildcard replacement
themselves.
Perl gives you @ARGV exactly as it gets expanded by the shell an passed
to Perl
look at the output of
echo ~/.*
Echo exactly replicates it's arguments. My shell replaces ~ with
/home/rhomberg and passes 76 arguments to echo.
To prevent this, use your shells favorite escape method
Backwhacks should work, or some flavour of quotes around the arguments.
Check with echo
- Alex
------------------------------
Date: 15 Oct 1999 19:54:31 GMT
From: neutron@fc.hp.com (Jack Applin)
Subject: Re: @ARGV ---- Arrrrgggghhhh! :-)
Message-Id: <7u80pn$a33$1@fcnews.fc.hp.com>
Tom Turton (tturton@ntx.waymark.net) wrote:
> I "want" to feed wildcard character filenames in via @ARGV, but it is
> seeking out matches and passing matched filenames in @ARGV. Is there
> any way to override this feature short of having to put quotes around my
> command line input?
One way around it is to not use @ARGV, but rather read the stuff in yourself,
like this:
$ move_em.pl
What do you want to move? abc*.xxx
Where do you want to move them to? def*.xxx
This way, the input doesn't pass through the shell, so wildcards
don't get expanded. As far as the interactive user is concerned,
it's the same number of keystrokes. I'd do it like this (untested):
if (@ARGV==2) { # Two arguments given?
($from, $to) = @ARGV; # Let's hope they were quoted
}
elsif (@ARGV==0 && -t) { # No arguments given--get some.
print "What do you want to move? ";
$from = <>; # Should check for EOF
print "Where do you want to move them to? ";
$to = <>; # Should check for EOF
}
else {
die "usage message\n";
}
-Jack Applin
neutron@fc.hp.com
------------------------------
Date: 15 Oct 1999 15:59:22 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: @ARGV ---- Arrrrgggghhhh! :-)
Message-Id: <slrn80f5cp.q8s.abigail@alexandra.delanet.com>
Tom Turton (tturton@ntx.waymark.net) wrote on MMCCXXXVI September
MCMXCIII in <URL:news:380753D5.52679512@ntx.waymark.net>:
..
.. I "want" to feed wildcard character filenames in via @ARGV, but it is
.. seeking out matches and passing matched filenames in @ARGV. Is there
.. any way to override this feature short of having to put quotes around my
.. command line input?
That's not a Perl question, but a shell question. Expanding of wildcards
is not done by Perl, but done by whatever shell you are using.
However, there's a Perl solution for everything, even shell problems!
perl -we 'system qw /move_em.pl abc*xxx def*.xxx/'
Abigail
--
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Fri, 15 Oct 1999 18:00:30 GMT
From: jasonnardone@my-deja.com
Subject: Alternatives to Net::Telnet
Message-Id: <7u7q3l$tc6$1@nnrp1.deja.com>
Hi everyone,
Problem: the Net::Telnet perl module is not installed where I work. I
need an alternative to execute a file on another machine. I do not
have root to install it. Can this be done any other way? such as
through Net::FTP or something? Thanks for your time.
J.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 15 Oct 1999 19:26:43 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: Alternatives to Net::Telnet
Message-Id: <7u7v5j$s7g$1@internal-news.uu.net>
jasonnardone@my-deja.com wrote:
> Problem: the Net::Telnet perl module is not installed where I work. I
> need an alternative to execute a file on another machine. I do not
> have root to install it. Can this be done any other way? such as
> through Net::FTP or something? Thanks for your time.
Yes. You can use cron to execute a script every minute, and use ftp
to upload that script.
Perhaps installing the Net::Telnet module in your own directory is
easier/smarter though.
Erik
from perlfaq8:
How do I keep my own module/library directory?
When you build modules, use the PREFIX option when generating Makefiles:
perl Makefile.PL PREFIX=/u/mydir/perl
then either set the PERL5LIB environment variable before you run scripts
that use the modules/libraries
(see perlrun) or say
use lib '/u/mydir/perl';
This is almost the same as:
BEGIN {
unshift(@INC, '/u/mydir/perl');
}
except that the lib module checks for machine-dependent subdirectories.
See Perl's lib for more information.
------------------------------
Date: Fri, 15 Oct 1999 19:09:28 GMT
From: "null" <agent@gte.net>
Subject: Re: Basic Domain name lookup
Message-Id: <IZKN3.277$Ee7.16990@dfiatx1-snr1.gtei.net>
I use the following which requires the cgi-lib.pl library. It can be easily
modified to use standard environment variables but I can't remember what
they are. If anyone knows them off-hand, I would appreciate it if you could
tell me for future reference.
(This perl script is used in a shell.... not on HTML)
It is not perfect but works for my own uses but might aid in the development
of you own.
#!/usr/local/bin/perl
#---------------------------------------------------------------------------
require "cgi-lib.pl";
&ReadParse;
&main;
#---------------------------------------------------------------------------
sub main {
local($buf);
if($in[0] ne "") {
$buf = `nslookup $in[0]`;
$buf = &filter($buf);
print "$buf\n\n";
}
else {
print "Error: Too few arguments\n\n";
}
}
#---------------------------------------------------------------------------
sub filter {
local($buf) = @_ if @_;
return substr(&findline($buf,"Name:"),9);
}
sub findline {
local($buf, $string) = @_ if @_;
local($i,$linebuf,$lineamt);
@linebuf = split("\n",$buf);
$lineamt = @linebuf;
for($i=0;$i<=$lineamt;$i++) {
$_ = $linebuf[$i];
if($_ =~ $string) {
$buf = $_;
break;
}
}
if($buf !~ $string) {
$buf = "";
}
return $buf;
}
Steve Bohler wrote in message <38071fcd.0@newsfeed.vitts.com>...
>Is there an existing Perl 'packaged' program out there which, when given an
>IP address, returns the domain name?
>
>I'm sure it's out there on the 'Net somewhere, but I haven't been able to
>find it.
>
>Any pointers would be appreciated.
>
>Steve
>
>
------------------------------
Date: Fri, 15 Oct 1999 12:58:30 -0700
From: Matthew Amster-Burton <mamster@mamster.net>
Subject: Re: Basic Domain name lookup
Message-Id: <38078766.853DD553@mamster.net>
null wrote:
> I use the following which requires the cgi-lib.pl library. It can be easily
> modified to use standard environment variables but I can't remember what
> they are.
Please, please, do not use or propagate this script.
1. It uses cgi-lib.pl, an obsolete library anyway, to do something that
does not require CGI.
2. It does the hostname lookup with a totally unportable call to an
external program instead of using the portable Perl built-in
gethostbyaddr.
Matthew
------------------------------
Date: Fri, 15 Oct 1999 17:50:49 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Can a perl script output image?
Message-Id: <7u7pq3$egt$1@news.mch.sbs.de>
In article <s0em94hhr0157@corp.supernews.com>, " Stacey" <stacey_hill50@hotmail.com> wrote:
>Can a perl script output an image? Some HTML files display images (eg hit
>counters) as the output of a cgi file. How is this done?
[snip]
If your webserver is running on some Windows platform, with binmode().
Have a look at the CGI Resource Index for 47 different examples :
<http://cgi.resourceindex.
com/Programs_and_Scripts/Perl/Access_Counters/Graphical/>
Michel.
------------------------------
Date: Fri, 15 Oct 1999 17:34:09 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: Can a perl script output image?
Message-Id: <38076548.867023814@news.ford.com>
[poster cc'd in e-mail]
On Fri, 15 Oct 1999 12:42:59 -0400, " Stacey"
<stacey_hill50@hotmail.com> wrote:
>Can a perl script output an image? Some HTML files display images (eg hit
>counters) as the output of a cgi file. How is this done?
>I found the following code in a web page.
>
><p align="center"><img
>src="http://www.myserver.com/cgi-bin/Count.cgi?id=abcdef"></p>
>
The trick is, when you call the header function, use a MIME type that
indicates you're sending an image:
print header(-type => 'image/jpeg');
You ARE using CGI.pm aren't you? :)
--
Clinton A. Pierce "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org Miracles." -- Miracle Max, The Princess Bride
http://www.geeksalad.org
------------------------------
Date: Fri, 15 Oct 1999 13:12:04 -0500
From: Seth David Johnson <sjohns17@uic.edu>
Subject: Re: Can a perl script output image?
Message-Id: <Pine.A41.4.10.9910151309180.422198-100000@tigger.cc.uic.edu>
On Fri, 15 Oct 1999, Stacey wrote:
> Can a perl script output an image? Some HTML files display images (eg hit
> counters) as the output of a cgi file. How is this done?
> I found the following code in a web page.
>
> <p align="center"><img
> src="http://www.myserver.com/cgi-bin/Count.cgi?id=abcdef"></p>
Well, if the image is changeable (as with hit counters), it's very likely
the code was written using the GD module, which may be used to generate
gifs (pngs after the unisys fiasco) on the fly. Otherwise, perl (like
anything else) can spit out a "Content-type: image/jpeg\n\n" or similar
HTTP header, followed by the contents of an image file.
-Seth
www.pdamusic.com
------------------------------
Date: Fri, 15 Oct 1999 19:44:01 GMT
From: marias@total.net
Subject: Re: Can a perl script output image?
Message-Id: <38078309.705077758@news.total.net>
This might be more complicated than you wanted, but this month's Linux
Journal (Oct. '99) has an easy to read and understandable article on
creating GIFs on the fly with perl from a relational database.
Apparently last months' also looked at GIFgraph which are Perl modules
to do so.
Maria
On Fri, 15 Oct 1999 12:42:59 -0400, " Stacey"
<stacey_hill50@hotmail.com> wrote:
>Can a perl script output an image? Some HTML files display images (eg hit
>counters) as the output of a cgi file. How is this done?
>I found the following code in a web page.
>
><p align="center"><img
>src="http://www.myserver.com/cgi-bin/Count.cgi?id=abcdef"></p>
>
>
>Thanks in advance,
>Stacey Hill
>
>
>
------------------------------
Date: Fri, 15 Oct 1999 19:40:51 GMT
From: Marcel Grunauer <marcel.grunauer@lovely.net>
Subject: Re: CGI Perl
Message-Id: <95AHOM8vVO1tScxRfrVOMkQhRvNF@4ax.com>
On Fri, 15 Oct 1999 08:09:12 +0100, Johnny 'Loopy' Ooi
<jjyooi@dcs.qmw.ac.uk> wrote:
> Is it possible to call a Perl script from within a Perl script? I'd like
> to have say a script deal with the background of a page and another deal
> with the text.
perldoc -f use
perldoc -f do
perldoc -f require
--
Marcel, Perl Padawan
sub AUTOLOAD{$_=$AUTOLOAD;s;.*::;;;y;_; ;;print}&Just_Another_Perl_Hacker;
------------------------------
Date: Fri, 15 Oct 1999 19:32:15 +0100
From: "SteveK" <SteveK@nyaaa.demon.co.uk>
Subject: Chat room scalability - on linux (apache)
Message-Id: <940012699.10382.0.nnrp-07.c1ed625d@news.demon.co.uk>
This is a multi-part message in MIME format.
------=_NextPart_000_0040_01BF1743.FCB91960
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi
=20
I have am working on a chat room project, written in perl, but I'm =
worried about it's scalability. I would appreciate your help:
Here are the main weak points of the script:
1) When the users send a chat message to the room it is written to a =
text file on the server. (max file size 2KB)
2) Every five seconds, each chat client (web browser ) calls a perl =
script, which then reads the text file and serves it to the clients.=20
=20
Scenarios:=20
=20
So, if fifty users are logged on and each user posts a message every =
five seconds then there will be ten file writes per second. Further, =
there will be ten file reads every second.=20
=20
Questions:
=20
1) Given that the file is being accessed ten times a second, will the =
file be cached in memory. And , if not, Is there a way to ensure that =
the file is cached (running it on Linux Apache).=20
=20
2) If the file is cached in memory, will it still be accessible to all =
processes -- i.e.. every time a browser calls the script a new process =
will be launched. would it still be possible to use the open (CHAT, =
"<filename.txt") command. Or will it be necessary to use IPC.
=20
3) Is it likely that this could be hosted on a shared server at the ISP, =
rather than as a standalone.
=20
4) Given that the file is cached in memory what would be the max number =
of writes (using flock) per second (assuming no more than a sentence is =
written at a time) - make as many other assumptions as you like - some =
of this will presumably depend on the build of Perl. Just a ballpark =
would be useful - i.e. correct to a factor of ten.
=20
=20
Yours, in search of knowledge
SteveK
------=_NextPart_000_0040_01BF1743.FCB91960
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>
<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.3110.7"' name=3DGENERATOR>
</HEAD>
<BODY>
<DIV>Hi
<DIV><FONT color=3D#000000 size=3D2></FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2><BR>I have am working on a chat room =
project,=20
written in perl, but I'm worried about it's scalability. I would=20
appreciate your help:</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>Here are the main weak points of the =
script:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=3D#000000 size=3D2>1) When the users send a chat =
message to the=20
room it is written to a text file on the server. (max file size=20
2KB)</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>2) Every five seconds, each =
chat client=20
(web browser ) calls a perl script, which then reads the text file and =
serves it=20
to the clients. </FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2><STRONG>Scenarios: =
</STRONG></FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>So, if fifty users are logged on and =
each user=20
posts a message every five seconds then there will be ten file writes =
per=20
second. Further, there will be ten file reads every second. =
</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT> </DIV>
<DIV><FONT color=3D#000000 =
size=3D2><STRONG>Questions:</STRONG></FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>1) Given that the file is =
being accessed=20
ten times a second, will the file be cached in memory. And , if =
not, Is=20
there a way to ensure that the file is cached (running it on Linux =
Apache).=20
</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>2) If the file is cached in memory, =
will it=20
still be accessible to all processes -- i.e.. every time a browser calls =
the=20
script a new process will be launched. would it still be possible to use =
the=20
open (CHAT, "<filename.txt") command. Or will it be =
necessary=20
to use IPC.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>3) Is it likely that this could be =
hosted on a=20
shared server at the ISP, rather than as a standalone.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>4) Given that the file is cached in =
memory what=20
would be the max number of writes (using flock) per second (assuming no =
more=20
than a sentence is written at a time) - make as many other assumptions =
as you=20
like - some of this will presumably depend on the build of Perl. Just a =
ballpark=20
would be useful - i.e. correct to a factor of ten.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT> </DIV>
<DIV> </DIV>
<DIV><FONT color=3D#000000 size=3D2>Yours, in search of =
knowledge</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>SteveK</FONT></DIV></DIV></BODY></HTML>
------=_NextPart_000_0040_01BF1743.FCB91960--
------------------------------
Date: Fri, 15 Oct 1999 20:46:14 GMT
From: nihilist@kenobiz.com (Max)
Subject: CLUELESS =(
Message-Id: <38079258.245780112@news.acronet.net>
ok, heres my problem.......http://www.kenobiz.com/problem.txt
i have NO clue what is wrong, i ran my perl syntax checker on it but
it comes up with nothing =(
------------------------------
Date: Fri, 15 Oct 1999 20:51:21 GMT
From: "Craig Vincent" <webmaster@webdream.com>
Subject: Re: CLUELESS =(
Message-Id: <dtMN3.278$cF.430@198.235.216.4>
Max <nihilist@kenobiz.com> wrote in message
news:38079258.245780112@news.acronet.net...
> ok, heres my problem.......http://www.kenobiz.com/problem.txt
> i have NO clue what is wrong, i ran my perl syntax checker on it but
> it comes up with nothing =(
Could you be a little more specific with your problem...ie what error
messages are you receiving when running it?
Have you tried adding strict & -w to the script to get more debugging info?
Craig Vincent
------------------------------
Date: 15 Oct 1999 18:42:39 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: DBD DELETE statement
Message-Id: <7u7siv$qmd$1@internal-news.uu.net>
jhagerty@my-deja.com wrote:
> I am trying to write a DELETE statement and i keep getting an error
> telling me I am giving too few parameters. I can't find and SQL
> statement help that was installed.
> If it's relevant , this is writing to an Access database.
That is relevent. Include as much relevant information as
possible. Ofcourse, the _exacty_ error message is the most
relevant piece here ... It is very well possible that your
SQL statement is not correct, which has nothing to do with
perl. Connect to database and see if the delete statement
works there.
Erik
------------------------------
Date: Fri, 15 Oct 1999 20:36:58 GMT
From: epan@my-deja.com
Subject: File Locking in Win32 PerlScript.
Message-Id: <7u8398$4kr$1@nnrp1.deja.com>
If I am to open a file for input in an ASP page
<%
open(FILE, ">>test.txt");
print FILE "Testing only.\n";
close(FILE);
%>
and there are a few users opening the page at the same time. Will the
file be locked until a user has closed the FILEHANDLE? If yes, it will
be a problem if 100 user open the page at the same time. Is there a
solution if that's the case?
Thanks.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 15 Oct 1999 20:12:07 GMT
From: wlanahan@att.com (Bill)
Subject: getting variables embeded in string to be evaluated
Message-Id: <380789e8.261577574@news.netnews.att.com>
#!/usr/local/bin/perl -w
#
# want to store an array of strings with embedded variables, in
particular
# hash values which are not know at the time the string is stored
# later after hash has been populated, want to print the strings
# can't get embdded vars to be evaluated
# note: array and hash may be very large with many subs per string
%ref = ();
@arr = ();
$_="hello YYY world\n";
print "ORIGINAL: \$_ = $_\n";
s/YYY/\$ref\{CC\}/;
print "NEW: \$_ = $_\n"; # just to see all is well
# now save this string but we don't have a value for the hash yet
$arr[0] = "$_";
$ref{CC} = "there"; # ok now the hash value is known
# we want to print the string and see
# the hash substituted
print "hash: $ref{CC}\n\n\n"; # just to see all is well
print "hoping to see: \"hello there world\"\n\n";
# get hello $ref{CC} world
print $arr[0];
print "$arr[0]";
#Tnx Bill
------------------------------
Date: Fri, 15 Oct 1999 15:07:19 -0500
From: Dan Baker <dtbaker_@busprod.com>
Subject: good salt for crypt() ?
Message-Id: <38078977.81879BEC@busprod.com>
I am writing a little utility to create a password file for uploading
and using in a simple .htaccess security scheme. I poked around for ways
to generate the encrypted passwords and it looks like the perl crypt()
function returns an encrypted string that can be used for this
purpose...
true so far?
After reading crypt() docs and poking some more, I found some references
indicating that some values for $salt would be better than others. Can
someone please explain why?
What would be good values to use for salt? I assume it should be some
changing value like time() or a random number rather than a hardcoded
string? I'm wondering just how carried away to get with this....
Thanx, Dan
# If you would like to reply-to directly, remove the - from my username
* no spam please... regulated by US Code Title 47, Sec.227(a)(2)(B) *
------------------------------
Date: Fri, 15 Oct 1999 20:47:47 GMT
From: fharris@xmission.com
Subject: Grabbing image size?
Message-Id: <38079276.22353035@news.xmission.com>
I'm interested in being able to grab the image dimensions from a .GIF
or .JPG picture using Perl. Anyone know how to do this?
Thanks,
Frank
------------------------------
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 1085
**************************************