[17084] in Perl-Users-Digest
Perl-Users Digest, Issue: 4496 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 2 18:16:57 2000
Date: Mon, 2 Oct 2000 15:16:37 -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: <970524996-v9-i4496@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 2 Oct 2000 Volume: 9 Number: 4496
Today's topics:
Re: Module Install on Solaris 8? <elaine@chaos.wustl.edu>
Re: Module Install on Solaris 8? (Garry Williams)
moving a module nlymbo@my-deja.com
Re: multiple file scoping nobull@mail.com
Re: multiple file scoping <brew1@voicenet.com>
Re: multiple file scoping <bmb@ginger.libs.uga.edu>
Re: multiple search and replace looking for a better wa <celliot@tartarus.uwa.edu.au>
Re: multiple search and replace looking for a better wa <stephenk@cc.gatech.edu>
Re: multiple search and replace looking for a better wa <lr@hpl.hp.com>
Re: newbie - flushing content to the browser (Steve A.)
Re: newbie - flushing content to the browser <jeff@vpservices.com>
Re: Newbie can't handle the "true"th... explanation de <tim@ipac.caltech.edu>
Re: Newbie can't handle the "true"th... explanation de (Jon S.)
Re: Newbie can't handle the "true"th... explanation de <ren.maddox@tivoli.com>
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: Newbie can't handle the "true"th... explanation de (Ilya Zakharevich)
Newby questions (Lawrence)
Re: Newby questions <gene@allsysinc.com>
Re: Perl CGI (Jon S.)
Re: Please critique this code (Andrew J. Perrin)
Re: Please critique this code <lr@hpl.hp.com>
Re: Please critique this code <bmb@ginger.libs.uga.edu>
Proving the greatness of mod_perl cmalcolm@my-deja.com
Re:flushing content to the browser (Steve A.)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 02 Oct 2000 21:02:26 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: Module Install on Solaris 8?
Message-Id: <B5FE701E.6E33%elaine@chaos.wustl.edu>
in article
021741285830A9BA.B9A196203B176E6A.56E4A25B0FB071E9@lp.airnews.net, Kent
Perrier at kperrier@blkbox.com quoth:
> Patrick Durusau <pdurusau@emory.edu> writes:
>> I am running gcc version 2.95.2 on a Solaris 8 box and cannot get
>> several Perl modules to compile.
>> Similar errors from other modules. I have a symbolic link from gcc to
>> cc.
In spite of the perceived utility of such a link, you shouldn't ever do that
as it will always bite you in the ass when you least expect it...like now.
:) If you make gcc not masquerade as cc you won't see this problem.
> The version of perl that comes with Sol8 was compiled with Sun Workshop, not
> gcc. The compiler options are being taken from the ones that were used to
> compile perl.
>
> At one time there was a post that listed the files that you could change so
> that you can use the Sol8 default perl and compile new modules with gcc.
> Perhaps a search through deja can lead you to it.
Out of curiosity that someone managed the impossible I went looking and only
found one message where someone had recommended an environment variable to
set CC to gcc....again, this is an ill fated hack usually, especially in
this case.
I would suggest compiling a Perl with gcc and installing it elsewhere than
the Sun installation so that you have yours separate...this will ensure that
all gcc versions are together and that you can still use the kstat tool and
that patches for the Sun version will work, etc.
e.
------------------------------
Date: Mon, 02 Oct 2000 21:58:14 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Module Install on Solaris 8?
Message-Id: <Wx7C5.233$b7.15729@eagle.america.net>
On Mon, 02 Oct 2000 21:02:26 GMT, Elaine Ashton
<elaine@chaos.wustl.edu> wrote:
>in article
>021741285830A9BA.B9A196203B176E6A.56E4A25B0FB071E9@lp.airnews.net, Kent
>Perrier at kperrier@blkbox.com quoth:
>> Patrick Durusau <pdurusau@emory.edu> writes:
>>> I am running gcc version 2.95.2 on a Solaris 8 box and cannot get
>>> several Perl modules to compile.
>>> Similar errors from other modules. I have a symbolic link from gcc to
>>> cc.
>
>In spite of the perceived utility of such a link, you shouldn't ever do that
>as it will always bite you in the ass when you least expect it...like now.
>:) If you make gcc not masquerade as cc you won't see this problem.
I bet the original poster saw another problem which led him to do this.
>> The version of perl that comes with Sol8 was compiled with Sun Workshop, not
>> gcc. The compiler options are being taken from the ones that were used to
>> compile perl.
>
>I would suggest compiling a Perl with gcc and installing it elsewhere than
>the Sun installation so that you have yours separate...this will ensure that
>all gcc versions are together and that you can still use the kstat tool and
>that patches for the Sun version will work, etc.
Good suggestion (assuming that Sun's compiler is not available). I
would suggest, if you do this that you also rename the /bin/perl
executable as well. The /bin directory often appears before others in
the PATH variable. That will cause your installed modules to be
masked.
Of course, if you have access to Sun's compiler, just remove the link
for gcc.
--
Garry Williams
------------------------------
Date: Mon, 02 Oct 2000 21:35:17 GMT
From: nlymbo@my-deja.com
Subject: moving a module
Message-Id: <8rav2m$bef$1@nnrp1.deja.com>
I have a perl module (*.pm) that i want to modify, but i don't want to
tamper with the original yet so i made a copy in the present working
directory. The package name of the module is Stnet::UserInput.pm...so
in the pwd i changed it to UserInput.pm. Then i modified the contents
and "used" it like so:
use UserInput;
@INC does include "." (pwd) so it should find the module but it does
not. Is there some other reason it would not be found. The message i
get is:
Can't locate auto/fk/UseInput/parse_billk.al in @INC (@INC
contains: /usr/local/
lib/perl5/5.00502/sun4-
solaris /usr/local/lib/perl5/5.00502 /usr/local/lib/perl5
/site_perl/5.005/sun4-solaris /usr/local/lib/perl5/site_perl/5.005 .)
at steve.p
l line 17
--
original guitar music at
http://www.mindspring.com/~nlymbo
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 02 Oct 2000 18:58:44 +0100
From: nobull@mail.com
Subject: Re: multiple file scoping
Message-Id: <u93difgm5n.fsf@wcl-l.bham.ac.uk>
Bruce Schiller <brew@theMode.com> writes:
> Is there a way to use lexical variables (my declarations) across multiple
> files
Not sensibly. (See perldoc -f do for a silly answer).
> or am I restricted to using fully qualified global declarations
> using local?
No, you can use fully qualified globals _or_ declared globals (you
don't need to do both). You can use either approach with _or_ without
using local. (Note: local() is not a declaration, 'use vars' or our()
is a declaration).
For a really slick approach declare your shared variables in a module
that inherits from Exporter. You can then use this module a bit like a
C header file.
> I want to use strict vars.
Good.
> The way I interpreted the docs I thought this might work:
>
> {
> my $var;
> require 'afile.pl';
It doesn't, see perldoc -f do
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 02 Oct 2000 19:43:35 GMT
From: Bruce Schiller <brew1@voicenet.com>
Subject: Re: multiple file scoping
Message-Id: <Hz5C5.1204$bt.20727@news3.voicenet.com>
Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
: The short answer is no. This is a Good Thing. You may find the why's and
: the how's in the following:
: perlmod Perl modules: how they work
: perlmodlib Perl modules: how to write and use
Both files are currently in the same package (namely, main).
I should have said what it is I'm trying to do, sorry! I have some
subroutines that are common to more than one program, so I'm hoping to put
them in a file and require them into each program. There are about 5
variables (arrays of pointers to hashes) that I have made global (except
that they are actually lexicals, declared at the opening of the program),
since I use them extensively all through the different programs, otherwise
I pass the vars in and/or define them lexically within the function.
Hence my question asking if lexical variables can straddle multiple files
(files that are in the same package). I don't think putting all my
subroutines in a different package would help me, unless I'm missing
something. Perlmod says separate packages are to help in making separate
namespaces, not sharing variables.
Thanks......
brew
--
==========================================================================
Strange Brew (brew@theMode.com)
Check out my Musician's Online Database Exchange (The MODE Pages)
http://www.TheMode.com
==========================================================================
------------------------------
Date: Mon, 2 Oct 2000 17:07:22 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: multiple file scoping
Message-Id: <Pine.A41.4.21.0010021646520.14510-100000@ginger.libs.uga.edu>
On Mon, 2 Oct 2000, Bruce Schiller wrote:
> Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
>
> : The short answer is no. This is a Good Thing. You may find the why's and
> : the how's in the following:
>
> : perlmod Perl modules: how they work
> : perlmodlib Perl modules: how to write and use
>
> Both files are currently in the same package (namely, main).
>
> I should have said what it is I'm trying to do, sorry! I have some
> subroutines that are common to more than one program, so I'm hoping to put
> them in a file and require them into each program. There are about 5
> variables (arrays of pointers to hashes) that I have made global (except
> that they are actually lexicals, declared at the opening of the program),
> since I use them extensively all through the different programs, otherwise
> I pass the vars in and/or define them lexically within the function.
The point is, don't do that, i.e., you don't want make them lexically
scoped if you have to use them in other files. On the other hand, you
don't want them to be globally scoped in the same namespace as the other
files, namely, main (usually). This type of namespace pollution might not
be a problem at the moment, but it will come back to bite you at some
point. You *want* those common subroutines to be in a separate package.
Then you can just import them into your other files' namespaces (e.g.,
main) with
use Packagename;
or
use Packagename LIST;
perlmod explains how to do this. Yes, it might be easier to let them be
global variables in main and simply require them, and yes, it's initially
a pain to learn how to make them into modules. However, it's the right
way to do it, and once you know how, you'll have a valuable tool for
creating even more useful subroutine libraries.
> Hence my question asking if lexical variables can straddle multiple files
> (files that are in the same package). I don't think putting all my
> subroutines in a different package would help me, unless I'm missing
> something. Perlmod says separate packages are to help in making separate
> namespaces, not sharing variables.
Yes, I think you're missing the point. The point is that packages help
you make separate namespaces so that you can *safely* share variables
among packages. You can make modules that use Exporter, or you can make
modules that implement object classes. Either way, by separating code and
variables into different packages, you can better and more safely use them
in other programs.
Brad
------------------------------
Date: Tue, 3 Oct 2000 02:45:01 +0800
From: "Cameron Elliott" <celliot@tartarus.uwa.edu.au>
Subject: Re: multiple search and replace looking for a better way
Message-Id: <39d8d7e9$0$930@echo-01.iinet.net.au>
This should help.. Its from another posting.......
just modify it for what you need..
----- Original Message -----
From: Bart Lateur <bart.lateur@skynet.be>
Newsgroups: comp.lang.perl.misc
Sent: Tuesday, October 03, 2000 2:01 AM
Subject: Re: benefits of arrays over hashes(associative arrays) and vice
versa
<snip>
For example, this
implements a quick HTML encoder:
%encode = ( '&' => '&', '<' => '<', '>' => '>');
foreach (@lines) {
s/([&<>])/$encode{$1}/g;
}
<snip>
--
Bart.
Ron Hill <hillr@ugsolutions.com> wrote in message
news:39D8BA90.C4148C70@ugsolutions.com...
| Hello,
|
| I have this script which searches and replaces chars. This does work but
| I was wondering is there a better way?
| Thanks
|
| #!/usr/bin/perl -w
| use strict;
|
| while (<main::DATA>) {
| print "before processing: $_";
| s/\&/\&/g || s/</\<\;/g || s/\"/\"\;/g || s/>/\>\;/g;
| print "After processing:$_";
| }
|
|
| __END__
| &&&&this is a test
| <this is a test<<<<
| """"this is a test""
| >this is>>>a>test>
|
------------------------------
Date: Mon, 02 Oct 2000 14:32:48 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: multiple search and replace looking for a better way
Message-Id: <39D8D4D0.3F45DEAD@cc.gatech.edu>
Ron Hill wrote:
> Hello,
>
> I have this script which searches and replaces chars. This does work but
> I was wondering is there a better way?
> Thanks
>
> #!/usr/bin/perl -w
> use strict;
>
> while (<main::DATA>) {
> print "before processing: $_";
> s/\&/\&/g || s/</\<\;/g || s/\"/\"\;/g || s/>/\>\;/g;
> print "After processing:$_";
> }
>
Use a hash to store character conversions:
%conv= qw(& & < < " " > >);
And then use a single s/// line for substitution:
s/[&<>"]/$conv{$&}/g;
HTH
--
Stephen Kloder | "I say what it occurs to me to say.
stephenk@cc.gatech.edu | More I cannot say."
Phone 404-874-6584 | -- The Man in the Shack
ICQ #65153895 | be :- think.
------------------------------
Date: Mon, 2 Oct 2000 12:57:32 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: multiple search and replace looking for a better way
Message-Id: <MPG.1442888838c1df0898adee@nntp.hpl.hp.com>
In article <39D8BA90.C4148C70@ugsolutions.com> on Mon, 02 Oct 2000
09:40:49 -0700, Ron Hill <hillr@ugsolutions.com> says...
> Hello,
>
> I have this script which searches and replaces chars. This does work but
> I was wondering is there a better way?
There are modules that do this, but I find it easier just to write it
out once in my own little collection of CGI/HTML-related functions, then
copy or include it in other programs as needed.
> #!/usr/bin/perl -w
> use strict;
>
> while (<main::DATA>) {
The 'main::' is implicit.
> print "before processing: $_";
Consistent indenting helps readability.
> s/\&/\&/g || s/</\<\;/g || s/\"/\"\;/g || s/>/\>\;/g;
Because of the short-circuiting logic, that would not change '<' on any
line containing '&', for example. I doubt that that is your desire.
Just replacing the || by semicolons would be better. But this is better
yet:
s/([&<">])/$escapes{$1}/g;
And, ahead of the loop, the definitions:
my %escapes =
( '&' => '&', '<' => '<', '"' => '"', '>' => '>' );
> print "After processing:$_";
> }
>
>
> __END__
> &&&&this is a test
> <this is a test<<<<
> """"this is a test""
> >this is>>>a>test>
>
>
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 29 Sep 2000 17:02:46 GMT
From: sarbayo@telis.org (Steve A.)
Subject: Re: newbie - flushing content to the browser
Message-Id: <39d4c817.4205332@news.inreach.com>
On Thu, 28 Sep 2000 19:40:59 GMT, jerome@activeindexing.com (Jerome
O'Neil) wrote:
>scottfreez@my-deja.com elucidates:
>> Whatever........I guess the fact that the program is written in Perl
>> has nothing to do with my reasons for posting it here?
>
>That is exacly correct. You would have the same problem if your
>program were written in COBOL. What does that tell you?
>
>--
what a bunch of assholes !
------------------------------
Date: Mon, 02 Oct 2000 11:29:30 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: newbie - flushing content to the browser
Message-Id: <39D8D40A.9D875B6F@vpservices.com>
"Steve A." wrote:
>
> On Thu, 28 Sep 2000 19:40:59 GMT, jerome@activeindexing.com (Jerome
> O'Neil) wrote:
>
> >scottfreez@my-deja.com elucidates:
> >> Whatever........I guess the fact that the program is written in Perl
> >> has nothing to do with my reasons for posting it here?
> >
> >That is exacly correct. You would have the same problem if your
> >program were written in COBOL. What does that tell you?
> >
> >--
> what a bunch of assholes !
We're assholes because we don't have an answer to un unanswerable
question? Ok, sorry for not inventing an answer. The answer is 17.
*plonk*
--
Jeff
------------------------------
Date: Mon, 02 Oct 2000 12:01:46 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Newbie can't handle the "true"th... explanation desired
Message-Id: <39D8DB9A.46716AE1@ipac.caltech.edu>
Larry Rosler wrote:
>
> > > Similarly, just what gets put into a variable when you set it as true
> > > or false?
> >
> > 1 and undef.
>
> No, it is 1 and the null string "", which is converted silently to 0 in
> arithmetic context.
Oops. Thanks for the correction. I'd swear I've read false was undef somewhere;
maybe in another erroneous Usenet posting!
--
-- Tim Conrow tim@ipac.caltech.edu |
------------------------------
Date: Mon, 02 Oct 2000 19:10:49 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: Newbie can't handle the "true"th... explanation desired
Message-Id: <39d8dd9d.21549446@news.earthlink.net>
On Fri, 29 Sep 2000 14:06:08 -0700, Larry Rosler <lr@hpl.hp.com>
wrote:
>In article <39d4fc12.26424851@news.earthlink.net> on Fri, 29 Sep 2000
>20:43:20 GMT, Jon S. <jonceramic@nospammiesno.earthlink.net> says...
>> (I also contemplated just giving it the string "true".)
>
>More characters to type. You could even use 'false', to drive the
>maintainers crazy.
LOL
Well, since I'm the maintainer, I think I'll just use "1".
Thanks everyone for the help. It's appreciated.
Jon
------------------------------
Date: 02 Oct 2000 15:24:39 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Newbie can't handle the "true"th... explanation desired
Message-Id: <m34s2vout4.fsf@dhcp11-177.support.tivoli.com>
Larry Rosler <lr@hpl.hp.com> writes:
> $name = undef; # The value of $name is now undefined.
>
> undef $name; # The variable $name no longer exists.
I'm trying to understand the semantics of this difference. At first,
I thought that perhaps defined would return a true value in the first
case, but that turned out to be false. Next, I thought perhaps a
reference to such a variable would somehow lose track of the variable,
but that didn't happen either.
From "perldoc -f undef":
undef EXPR
Undefines the *value* of EXPR, which must be an lvalue.
(emphasis added).
On all experiments I have tried, "undef $name" and "$name = undef"
appear to have the same effect. To wit:
#!/usr/local/bin/perl -w
use strict;
my $x = 5;
my $y = \$x; print "$y: $$y\n";
undef $x; print "$y: $$y\n";
$x = 4; print "$y: $$y\n";
$x = undef; print "$y: $$y\n";
$x = 3; print "$y: $$y\n";
$y = \$x; print "$y: $$y\n";
__END__
Note that some of these test are a bit paranoid. Naturally, the value
of $y never changes. Neither form of undef destroys $x, just its
value. Using package variables produces the same results.
What then, is the difference?
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Mon, 2 Oct 2000 17:12:33 -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.0010021709430.14510-100000@ginger.libs.uga.edu>
On Mon, 2 Oct 2000, Jon S. wrote:
> On Fri, 29 Sep 2000 14:06:08 -0700, Larry Rosler <lr@hpl.hp.com>
> wrote:
>
> >In article <39d4fc12.26424851@news.earthlink.net> on Fri, 29 Sep 2000
> >20:43:20 GMT, Jon S. <jonceramic@nospammiesno.earthlink.net> says...
> >> (I also contemplated just giving it the string "true".)
> >
> >More characters to type. You could even use 'false', to drive the
> >maintainers crazy.
>
> LOL
>
> Well, since I'm the maintainer, I think I'll just use "1".
>
> Thanks everyone for the help. It's appreciated.
>
> Jon
>
OTOH, you could do this and just not care what the value actually is,
my $true = 1==1;
my $false = 1==0;
Brad
------------------------------
Date: Mon, 2 Oct 2000 14:04:06 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Newbie can't handle the "true"th... explanation desired
Message-Id: <MPG.1442982594f87f9a98adf2@nntp.hpl.hp.com>
In article <m34s2vout4.fsf@dhcp11-177.support.tivoli.com> on 02 Oct 2000
15:24:39 -0500, Ren Maddox <ren.maddox@tivoli.com> says...
> Larry Rosler <lr@hpl.hp.com> writes:
>
> > $name = undef; # The value of $name is now undefined.
> >
> > undef $name; # The variable $name no longer exists.
>
> I'm trying to understand the semantics of this difference. At first,
> I thought that perhaps defined would return a true value in the first
> case, but that turned out to be false. Next, I thought perhaps a
> reference to such a variable would somehow lose track of the variable,
> but that didn't happen either.
...
> What then, is the difference?
For other than a lexical variable, whether or not the name actually
exists in the symbol table. What the imnplications of this are (if any)
I don't know, because I have never had to muck around at that level of
coding.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 2 Oct 2000 21:45:54 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Newbie can't handle the "true"th... explanation desired
Message-Id: <8ravmi$l70$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Ren Maddox
<ren.maddox@tivoli.com>],
who wrote in article <m34s2vout4.fsf@dhcp11-177.support.tivoli.com>:
> > $name = undef; # The value of $name is now undefined.
> >
> > undef $name; # The variable $name no longer exists.
>
> I'm trying to understand the semantics of this difference.
undef WHATEVER
- clears the memory buffers associated for WHATEVER
$var = undef;
- marks the memory buffers as unapplicable;
So there is no difference from the Perl side. All the difference is
in performance. Using $var = undef keeps the buffers ready for the
next time something is going to be assigned to $var, so is a speed
optimization. Using undef $var free()es memory used by buffers, so it
is a space optimization.
Your choice - but only if the situation is so bad that you need
microoptimizations. Otherwise they are synonyms.
Ilya
------------------------------
Date: Mon, 02 Oct 2000 19:14:56 GMT
From: lawrencedeans@NoSpam.genie.co.uk (Lawrence)
Subject: Newby questions
Message-Id: <39d8de75.5002590@news.freeserve.net>
Hi
I hope this is the right place to ask but I've been analysing a few
scripts. I would like to fully understand, well almost, the paths and
processes the data follows from input forms. I want to write or at
least tweak existing scripts for my own use.
The following piece of code parses data input but I don't fully
understand the process, I have entered comments and questions and
would like some advice hence my post.
sub parse_form {
my($buffer,$pair,$value,@pairs,$name);
#what is my()?
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
#reads string of input from form to $buffer variable!
if (length($buffer) < 4) {
$buffer = $ENV{QUERY_STRING};
}
#what does the above bit do?
@pairs = split(/&/, $buffer);
#splits the contents of $buffer into name-value pairs and places
into the array @pairs
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
#splits each element of @pairs into name and value variables $name,
$value
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
#what does the above process on the $value variable do?
$FORM{$name} = $value;
#$name variables receive contents of $value variables
}
}
Regards Lawrence
------------------------------
Date: Mon, 02 Oct 2000 19:27:58 GMT
From: "Gene" <gene@allsysinc.com>
Subject: Re: Newby questions
Message-Id: <2l5C5.850$Kc.86948@news.flash.net>
I have notated the code so that it should make some more sense
> sub parse_form {
> my($buffer,$pair,$value,@pairs,$name);
> #what is my()? -- my() adjusts the scope of the variables to just this
function
>
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> #reads string of input from form to $buffer variable! -- very good!
>
> if (length($buffer) < 4) {
> $buffer = $ENV{QUERY_STRING};
> }
> #what does the above bit do? -- the above bit is because there are two
ways to pass data from a form.
> # you can pass them with the GET or POST methods. This tests if the
first method didn't provide much data,
> # then to try the other one. The QUERY_STRING is what is passed in
the URL. You know, all that garbage that shows up?
>
> @pairs = split(/&/, $buffer);
> #splits the contents of $buffer into name-value pairs and places
> into the array @pairs -- very good, except one thing the name-value pairs
look more like name=value.
>
> foreach $pair (@pairs) {
> ($name, $value) = split(/=/, $pair);
> #splits each element of @pairs into name and value variables $name,
> $value -- good
>
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> #what does the above process on the $value variable do? -- the tr///
thing converts all + to spaces. That is because
> # the spaces show up as + in the data passed to the script. The next
line convers all hex data into it's proper characters.
> # you will notice that often in the URL, you will see %2f or %2e
>
> $FORM{$name} = $value;
> #$name variables receive contents of $value variables -- almost. this
creates an associative array. it looks like the following:
> # $FORM{'name1'} = value1
> # $FORM{'name2'} = value2
> # this way you can get all of the form data from the $FORM
associative array.
> }
> }
>
> Regards Lawrence
------------------------------
Date: Mon, 02 Oct 2000 19:31:09 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: Perl CGI
Message-Id: <39d8e266.22774310@news.earthlink.net>
On Mon, 02 Oct 2000 10:48:27 GMT, Bart Lateur <bart.lateur@skynet.be>
wrote:
>Young Chi-Yeung Fan wrote:
>
>>use CGI::Carp qw(fatalsToBrowser);
>>
>>Is there anything else I can put in there to help me debug easier? I
>>think I saw a post about that last week, but I'm having trouble finding
>>it.
>
>Does this automatically send error messages to the browser? I think not.
>I'm used to that, but I made my own library.
The newest version also has warningsToBrowsers (double check the caps
on that).
Jon
------------------------------
Date: 02 Oct 2000 13:44:12 -0400
From: aperrin@demog.berkeley.edu (Andrew J. Perrin)
Subject: Re: Please critique this code
Message-Id: <u1yxzw32r.fsf@demog.berkeley.edu>
Jim Cook <jcook@strobedata.com> writes:
> Ok, I'm listening. I'd love to be educated.
My 2c: you've done a lot right; some comments below. I generally don't
like first-cap variable names so would use $file, $depth, etc., but
personal taste....
>
> #############################################
> #! perl -w
> use strict;
>
> my $File = shift || die "Need a filename";
> my $Depth = shift || die "Need a depth";
>
> print "Opening file ";
> open (IN, $_ = $File) || die "$_: $!";
> print "\nReading file ";
> my $Text = join("", <IN>);
> print length($Text) . "\nCleaning EOL ";
> $Text =~ tr/\r\n/ /;
> $Text =~ tr/./#/;
Use s// in the previous instead of tr//.
$Text =~ s/\./#/g;
$text =~ s/\r\n/ /g;
> print length($Text) . "\nCleaning meta characters ";
> $Text =~ s/[^A-Za-z\'\,\s#]//g;
No need for all those backslashes:
s/[^A-Za-z',\s#]//g;
> print length($Text) . "\nCleaning doubled spaces ";
> $Text =~ s/\s\s+/ /g while $Text =~ /\s\s+/;
This is a job for tr//:
$Text =~ tr/ / /s;
> print length($Text) . "\n";
> close IN;
>
> my $Running = substr($Text, rand(length($Text)) - 100, $Depth);
> print "\n";
> print $Running;
> my %Found;
>
> my $i = 0;
>
> while (1) {
> while (!(defined $Found{$Running})) {
I find it a little cleaner to use until, but that's just personal taste:
until (defined $Found{$Running}) {
> my $matches = join("", ($Text =~ /$Running(.)/g));
> if ($matches eq "") {
> print "\n\n";
> $Running = substr($Text, rand(length($Text)) - 100, $Depth);
> }
> else {
> $Found{$Running} = $matches;
> }
> }
>
> my $newletter = substr($Found{$Running},
> rand(length($Found{$Running})), 1);
>
> $Running = substr($Running, 1, $Depth - 1) . $newletter;
>
> $newletter = ".\n\n" if $newletter eq "#";
> print $newletter;
> }
>
>
>
--
----------------------------------------------------------------------
Andrew Perrin - Solaris-Linux-NT-Samba-Perl-Access-Postgres Consulting
aperrin@igc.apc.org - http://demog.berkeley.edu/~aperrin
----------------------------------------------------------------------
------------------------------
Date: Mon, 2 Oct 2000 13:11:04 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Please critique this code
Message-Id: <MPG.14428bb4e7c81ec098adef@nntp.hpl.hp.com>
In article <u1yxzw32r.fsf@demog.berkeley.edu> on 02 Oct 2000 13:44:12 -
0400, Andrew J. Perrin <aperrin@demog.berkeley.edu> says...
> Jim Cook <jcook@strobedata.com> writes:
...
> > $Text =~ tr/\r\n/ /;
> > $Text =~ tr/./#/;
>
> Use s// in the previous instead of tr//.
>
> $Text =~ s/\./#/g;
Why? tr/// is a lot faster.
> $text =~ s/\r\n/ /g;
Different semantics. That replaces the sequence "\r\n" by a space.
The tr/// replaces each "\r" or"\n" by a space.
$text =~ tr/.\r\n/# /;
> > print length($Text) . "\nCleaning meta characters ";
> > $Text =~ s/[^A-Za-z\'\,\s#]//g;
>
> No need for all those backslashes:
>
> s/[^A-Za-z',\s#]//g;
Once again, the better way to do this is with tr///
tr/A-Za-z', \r\n\f\t#//cd;
Note that any "\r" and "\n" have already become space characters.
> > print length($Text) . "\nCleaning doubled spaces ";
> > $Text =~ s/\s\s+/ /g while $Text =~ /\s\s+/;
>
> This is a job for tr//:
>
> $Text =~ tr/ / /s;
So were the others! :-)
...
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 2 Oct 2000 17:17:02 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Please critique this code
Message-Id: <Pine.A41.4.21.0010021714260.14510-100000@ginger.libs.uga.edu>
On 2 Oct 2000, Andrew J. Perrin wrote:
> Jim Cook <jcook@strobedata.com> writes:
>
> > Ok, I'm listening. I'd love to be educated.
>
> My 2c: you've done a lot right; some comments below. I generally don't
> like first-cap variable names so would use $file, $depth, etc., but
> personal taste....
>
> >
> > #############################################
> > #! perl -w
> > use strict;
> >
> > my $File = shift || die "Need a filename";
> > my $Depth = shift || die "Need a depth";
In addition, first-cap names are by convention usually reserved for
modules/packages.
Brad
------------------------------
Date: Mon, 02 Oct 2000 20:25:57 GMT
From: cmalcolm@my-deja.com
Subject: Proving the greatness of mod_perl
Message-Id: <8rar0b$7nm$1@nnrp1.deja.com>
Is there a list of major web sites that are using mod_perl
succesfully? I am trying to persuade some investors that we are great,
because we want to use mod_perl to build a site that will potentially
be very large.
The people assessing us seem to think that Perl is no good for these
reasons:
1) It is good for prototyping, but is bad for a site that must be
highly scalable.
2) It is too slow.
3) It is not object-oriented (They listen for words like "Java"
and "C++" to decide if something is object-oriented).
4) They have not heard of mod_perl before.
5) They say you can't employ 'Perl certified engineers'!!!
So, I have a choice:
A) Abandon Perl with mod_perl and start using Java
B) Try and educate these guys.
The thing is, it seems to me that if you are trying to pursuade someone
to invest in your idea, they will employ consultants to assess you, and
these consultants only know about commercial, proprietry stuff, such as
Java, Oracle, OAS, etc.
How can I educate these people? It is absolutely infurating that
companies such as Oracle can get their software in use, just by
brainwashing people in important places that it is the only way
forward. Whilst Oracle _is_ good, it is not what we need.
We firmly believe, in fact we KNOW, that mod_perl makes perl the best
choice for our application. We know that these consultants are just
plain ignorant.
What can be done to persuade people that mod_perl is a viable
solution? I don't want to be forced to change our whole development
plan just to satisfy some consultants who are not up to date on these
things!
Cheers,
Chris.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 27 Sep 2000 15:36:23 GMT
From: sarbayo@telis.org (Steve A.)
Subject: Re:flushing content to the browser
Message-Id: <39d20fd5.1518950@news.inreach.com>
On Wed, 27 Sep 2000 01:32:22 GMT, scottfreez@my-deja.com wrote:
()>I'm writing a link checker that loops through an array of links,
()checks them and then outputs the results to the browser as well as a
()database.
()>As my list of links is up around 60,000, I'd like to be able to
()have the results of each iteration of the checker loop sent
()straight to the browser.
()> Or, maybe break them into chunks of 50 or 100. As it stands
()now, it flushes periodically and I'm not sure what is causing it to
()do this.
() Can someone either tell me 1) how to control the flushing, or 2)
()what causes the server/program(?) to flush the results? I'm running
()the program on IIS.
()>Any insight would be much appreciated.
()>thanks,
()>scottfreez
Hi Scott,
This is similar to the question I posed prior to yours, titled :
"?? wait for a browser response ",
where I'm want to wait for the browser to acknowlege reciept of info,
before program continues.
I've had no feedback yet.
I was reading where you flush a device/handle, but I don't know it
that translates to " flush(STDOUT) " or not.
I also read where the STDIN/OUT is buffered, as are all device/handles
and they don't flush until they are full or closed.
That's the problem I'm running into.
I think I'll resubmit under a new title.
Steve A.
------------------------------
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 4496
**************************************