[17691] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5111 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 14 14:05:40 2000

Date: Thu, 14 Dec 2000 11:05:17 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <976820717-v9-i5111@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 14 Dec 2000     Volume: 9 Number: 5111

Today's topics:
    Re: "is JScript enabled" via perl <mbudash@sonic.net>
    Re: #include files? sort of <mjcarman@home.com>
    Re: #include files? sort of (Stan Brown)
    Re: #include files? sort of nobull@mail.com
    Re: [OT]: newline -- Was:  ??newbie: s/// and \r <mischief@velma.motion.net>
    Re: a little off topic (Abigail)
    Re: a little off topic <schneider@xtewa.de>
    Re: a little off topic (Anno Siegel)
    Re: a little off topic (Abigail)
        Ada feature borrowed for Perl?? <ralawrence@my-deja.com>
    Re: Ada feature borrowed for Perl?? <jeff_robertson@yahoo.com>
    Re: Ada feature borrowed for Perl?? (Tom Christiansen)
        Dereferencing hash within hash (Dave Sherohman)
    Re: Dereferencing hash within hash (Garry Williams)
    Re: Dereferencing hash within hash (Dave Sherohman)
    Re: Does comp.lang.perl exist? Yes! <mischief@velma.motion.net>
    Re: Eliminating unneeded whitespace... <mischief@motion.net>
    Re: Eliminating unneeded whitespace... <mischief@velma.motion.net>
    Re: Eliminating unneeded whitespace... <jeffp@crusoe.net>
    Re: Help! Problem with file uploads using CGI module hroces@my-deja.com
    Re: Hopefully not to difficult a question. Please Help msalerno@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 14 Dec 2000 09:58:14 -0800
From: Michael Budash <mbudash@sonic.net>
Subject: Re: "is JScript enabled" via perl
Message-Id: <mbudash-2B2E12.09581414122000@news.pacbell.net>

In article <91a6rr$drb$1@nnrp1.deja.com>, SimBean <schneider@xtewa.de> 
wrote:

> > > Is there a way to determine _via perl_ whether or not a user has
> JScript
> > > enabled in his or her browser??
> >
> > no, but you can put jscript on a web page that will cause a perl cgi
> > script to be *told* that it (jscript) is enabled...
>
> Thanks alot, I think this will be perfect for the job.
> 
> Thanks again.
> 

you're welcome... let us see what you come up with...
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Thu, 14 Dec 2000 09:35:19 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: #include files? sort of
Message-Id: <3A38E8B7.5EAF4AB0@home.com>

Stan Brown wrote:
> 
> I have a small perl script that will eventually be one of a pair
> of co-operating tasks. I am planing on using on confiugration 
> file for both tasks. Since the code for pareseing this file is 
> common, I wnat to pull it out into a file to "#included" by both
> scripts.

Ah, a C programmer. In Perl, we 'use' or 'require' files.

> Hees what I have at the top of the existing script.

[Snip!]
Since your code (presumably) works, we don't really need to see all 100+
lines of it. :)

> What I want to do, is put this section it it's own file, and 
> have the global varibales, and the subroutine be accessiable 
> to booht scripts.

You want a module.

> I have read the section in the Camel book on modules, and 
> packages (Chapter 5), but I'm a bit overwhelmed.

Good! You've figured out what you need and have started working on how
to do it. You should also have a look at the perlmod manpage. Which
portions of the book/docs were unclear to you?

In a nutshell, what you want to do is create a separate file, put all
your global vars and your sub in it, tell it to export them, and then
put a 'use Foo' in each of your main scripts, where 'Foo' whatever you
choose to name your module.

-mjc


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

Date: 14 Dec 2000 11:58:40 -0500
From: stanb@panix.com (Stan Brown)
Subject: Re: #include files? sort of
Message-Id: <91au80$mrt$1@panix3.panix.com>

In <3A38E8B7.5EAF4AB0@home.com> Michael Carman <mjcarman@home.com> writes:

>Stan Brown wrote:
>> 
>> I have a small perl script that will eventually be one of a pair
>> of co-operating tasks. I am planing on using on confiugration 
>> file for both tasks. Since the code for pareseing this file is 
>> common, I wnat to pull it out into a file to "#included" by both
>> scripts.

>Ah, a C programmer. In Perl, we 'use' or 'require' files.

	Guilty as charged :-)

>> Hees what I have at the top of the existing script.

>[Snip!]
>Since your code (presumably) works, we don't really need to see all 100+
>lines of it. :)

	Uh, that wasn't all 1000+ lines of it, just enough to give a context
	for my question, or so I thought. I apologize.

>> What I want to do, is put this section it it's own file, and 
>> have the global varibales, and the subroutine be accessiable 
>> to booht scripts.

>You want a module.

>> I have read the section in the Camel book on modules, and 
>> packages (Chapter 5), but I'm a bit overwhelmed.

>Good! You've figured out what you need and have started working on how
>to do it. You should also have a look at the perlmod manpage. Which
>portions of the book/docs were unclear to you?

>In a nutshell, what you want to do is create a separate file, put all
>your global vars and your sub in it, tell it to export them, and then
>put a 'use Foo' in each of your main scripts, where 'Foo' whatever you
>choose to name your module.

	Ah, I think it's teh exporting thing I have not figured out.

	Thanks, gven that clue, I will re-read the book, and look at the perdoc
	manual also.

	Thanks.

	Learning things is fun.



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

Date: 14 Dec 2000 18:25:24 +0000
From: nobull@mail.com
Subject: Re: #include files? sort of
Message-Id: <u9g0jq6esr.fsf@wcl-l.bham.ac.uk>

stanb@panix.com (Stan Brown) writes:

> 	I have a small perl script that will eventually be one of a pair of
> 	co-operating tasks. I am planing on using on confiugration file for
> 	both tasks. Since the code for pareseing this file is common, I wnat to
> 	pull it out into a file to "#included" by both scripts.

By "#included" you probably mean used or required.

> 	What I want to do, is put this section it it's own file, and have the
> 	global varibales, and the subroutine be accessiable to booht scripts.
> 
> 	I have read the section in the Camel book on modules, and packages
> 	(Chapter 5), but I'm a bit overwhelmed. 
> 
> 	How can I acomplish this in a simple manner?

You are free to fall back on Perl4 techniques and simply require the
file.  Ignore all the stuff about modules, all you need to do is put
"1;" on the last line of the file and act like you'd used #include in
C.

That said, using an "Exporter" module is the better more-Perl5ish way.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 14 Dec 2000 17:06:16 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: [OT]: newline -- Was:  ??newbie: s/// and \r
Message-Id: <t3hvg8k9fl4iba@corp.supernews.com>

Linc Madison <lincmad001@telecom-digest.zzn.com> wrote:
> In article <3A38B296.1B20FB27@fujitsu-siemens.com>, Josef Moellers
> <josef.moellers@fujitsu-siemens.com> wrote:

>> \012 is "newline".

> Only because Unix DEFINED it that way. ASCII does *NOT* define \012 as
> "newline."

And someone else defined "carriage return" to be "newline" instead
of defining "line feed" to be "newline". I have to wonder the
difference between automatically feeding a line when you return the
carriage to the left and automatically returning the carriage to
the left when you feed a line. Both accomplish the same thing,
and neither really has much bearing on what an OS really does.
I guess there might be times when it would be handy to do one
without the other, but having a default of doing both is
reasonable. TMTOWTDI.

> \012 is "LINE FEED" which is NOT the same thing as "newline" to the
> rest of the world.

\012 is newline, which to the rest of the world, when they use
Unix variants, is newline. Elsewhere, it is different. TMTOWTDI.

No one claims that Unix redefines ASCII. Unix makes definitions
for Unix. You could also say that neither CONTROL-D (End of
Transmission) or CONTROL-Z (Substitute) deserves to be end-of-file.
They each are in one place or another. ;)

The best guess I can muster for why these codes were used is that
they were included in ASCII, someone didn't want to make a code
that was being used for something else change meaning in the
environment they were using, and these were the codes that were
available for use in the environment since they weren't being used
for their original designations.


> (Yes, I was wrong about vertical tab, but I'm right about line feed.)

> Line Feed is a poor choice for a newline character, objectively
> speaking, since it has a fundamentally INCOMPATIBLE meaning.

Not really. Going down a line and over is the same as going over
and down a line. TMTOWTDI.

> The carriage return has a meaning that is fundamentally COMPATIBLE with
> "newline," because carriage return means return to the leftmost column
> of output. Line Feed does NOT contain that meaning.

And carriage return does not include going down a line. If I return
my carriage on a typerwriter to the left and don't fee the line,
everything types from left to right, but over the previous line.

If I go down a line but don't return the carriage, I end up on a new
line at my current horizontal position. Neither one contains all the
meaning of newline. There happen to be things in the world that are
not perfect - that have impurities or inconsistencies. Basically,
you need to know what you can change and what you can't, and then
learn how to change what you can and how to live with what you can't.

You specifically need to realize that TMTOWTDI, especially when you're
posting to a group for Perl, where this is a central idea of the
language and a central ideal of the group.

Mostly, people just want to get the job done, and using \012 or
\015 or \012 or even \003 (End of Text) or \036 (Record
Separator) to mean what you want it to mean gets the job done.

Speaking of standards, does POSIX say anything about
end-of-line/newline?

Chris
--
Christopher E. Stith - mischief@motion.net


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

Date: 14 Dec 2000 16:33:16 GMT
From: abigail@foad.org (Abigail)
Subject: Re: a little off topic
Message-Id: <slrn93htic.elk.abigail@tsathoggua.rlyeh.net>

On Thu, 14 Dec 2000 14:58:40 GMT, SimBean (schneider@xtewa.de) wrote in comp.lang.perl.misc <URL: news:<91an6s$qg5$1@nnrp1.deja.com>>:
++ Hi Abigail,
++ 
++ I came across that japh of yours and I just cannot figure it out!
++ 
++ push @INC => sub {($\ = pop) =~ s/\..*/ /; print ""};
++ eval "use Just" || eval "use another" || eval "use Perl" || eval "use
++ Hacker";
++ 
++ Could you explain what you are doing there, please. :)
++ I searched faq and doc but it didn't help me understand it ...


Go to www.perl.com and read the most recent summary of p5p.


Abigail
-- 
use   lib sub {($\) = split /\./ => pop; print $"};
eval "use Just" || eval "use another" || eval "use Perl" || eval "use Hacker";


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

Date: Thu, 14 Dec 2000 17:10:56 GMT
From: SimBean <schneider@xtewa.de>
Subject: Re: a little off topic
Message-Id: <91auun$1u9$1@nnrp1.deja.com>


> Go to www.perl.com and read the most recent summary of p5p.
p5p is perl 5 porters?!?

Sorry, couldn't find anything about that at perl.com ...
I think I may just have to learn _alot_ more. :/

--
Ciao,
SimBean.


Sent via Deja.com
http://www.deja.com/


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

Date: 14 Dec 2000 17:23:15 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: a little off topic
Message-Id: <91avm3$t9c$1@lublin.zrz.tu-berlin.de>

Abigail <abigail@foad.org> wrote in comp.lang.perl.misc:
>On Thu, 14 Dec 2000 14:58:40 GMT, SimBean (schneider@xtewa.de) wrote in comp.lang.perl.misc <URL: news:<91an6s$qg5$1@nnrp1.deja.com>>:
>++ Hi Abigail,
>++ 
>++ I came across that japh of yours and I just cannot figure it out!
>++ 
>++ push @INC => sub {($\ = pop) =~ s/\..*/ /; print ""};
>++ eval "use Just" || eval "use another" || eval "use Perl" || eval "use
>++ Hacker";
>++ 
>++ Could you explain what you are doing there, please. :)
>++ I searched faq and doc but it didn't help me understand it ...
>
>
>Go to www.perl.com and read the most recent summary of p5p.

Damn.  I read that, but it didn't sink in.

If anyone cares, the crucial point is an undocumented feature of
the @INC array: If you push a coderef on there (instead of the
usual string indicating a directory), the code is executed when
a use statement later tries to load a module from that non-directory.
It is called with two parameters, the second of which is the
module name.  The rest of Abigail's japh is standard obfuscation,
sterling work, but nothing extraordinary.  The use of eval() serves
a double purpose: It delays the execution of use() to run-time, so
there's no fiddling with BEGIN blocks, and it suppresses the error
message when the modules are not found.

Anno


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

Date: 14 Dec 2000 17:26:09 GMT
From: abigail@foad.org (Abigail)
Subject: Re: a little off topic
Message-Id: <slrn93i0lh.elk.abigail@tsathoggua.rlyeh.net>

On Thu, 14 Dec 2000 17:10:56 GMT, SimBean (schneider@xtewa.de) wrote in comp.lang.perl.misc <URL: news:<91auun$1u9$1@nnrp1.deja.com>>:
++ 
++ > Go to www.perl.com and read the most recent summary of p5p.
++ p5p is perl 5 porters?!?

Yes.

++ Sorry, couldn't find anything about that at perl.com ...
++ I think I may just have to learn _alot_ more. :/

It's there.


Abigail


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

Date: Thu, 14 Dec 2000 18:23:47 GMT
From: Richard Lawrence <ralawrence@my-deja.com>
Subject: Ada feature borrowed for Perl??
Message-Id: <91b37a$61h$1@nnrp1.deja.com>

According to http://www.perl.com/pub/2000/12/advocacy.html?
wwwrrr_20001213.txt ...

"Perl got where it is today by copying a lot of stuff from a lot of
other languages. Perl's most famous features, hashes and regexes, are
copied from Unix utilities like AWK, grep, and sed. Perl's statement
modifiers are borrowed from BASIC-plus, of all places. Perl even has
features that are borrowed from Ada, including one feature you use
every day."

Having done Ada for 2 years and Perl for about a year I'm ashamed to
admit I have no idea what that feature is. Granted I haven't touched
Ada in 5 years and granted i'm not that great at Perl or Ada but can
anyone tell me what on earth it was that was borrowed??

Rich


Sent via Deja.com
http://www.deja.com/


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

Date: Thu, 14 Dec 2000 18:44:10 GMT
From: Jeff Robertson <jeff_robertson@yahoo.com>
Subject: Re: Ada feature borrowed for Perl??
Message-Id: <91b4dp$734$1@nnrp1.deja.com>

In article <91b37a$61h$1@nnrp1.deja.com>,
  Richard Lawrence <ralawrence@my-deja.com> wrote:
>
> Having done Ada for 2 years and Perl for about a year I'm ashamed to
> admit I have no idea what that feature is. Granted I haven't touched
> Ada in 5 years and granted i'm not that great at Perl or Ada but can
> anyone tell me what on earth it was that was borrowed??

Packages ?

Larry Wall has also mentioned Ada when defending Perl's lack of multi-
line comments, but I think this was a joke. Perl's comment syntax
obviously comes from sh and/or awk.

--
"I'm a snotty E-commerce server software coder." - Joona Palaste, c.l.c.
http://www.geocities.com/jeff_robertson


Sent via Deja.com
http://www.deja.com/


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

Date: 14 Dec 2000 12:01:18 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: Ada feature borrowed for Perl??
Message-Id: <3a3918fe$1@cs.colorado.edu>

In article <91b37a$61h$1@nnrp1.deja.com>,
Richard Lawrence  <ralawrence@my-deja.com> wrote:
>Having done Ada for 2 years and Perl for about a year I'm ashamed to
>admit I have no idea what that feature is. Granted I haven't touched
>Ada in 5 years and granted i'm not that great at Perl or Ada but can
>anyone tell me what on earth it was that was borrowed??

main'func, for one.

--tom


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

Date: Thu, 14 Dec 2000 18:00:10 GMT
From: esper@news.visi.com (Dave Sherohman)
Subject: Dereferencing hash within hash
Message-Id: <slrn93i2l8.i0u.esper@pchan.sherohman.org>

I've got a hash of hashes and it seems to be behaving oddly when I try to
extract one of the contained hashes...  (Yes, I know I could just use
$hoh{'key1'}{'key2'}.  But I don't like that construct when the contained
hash is going to be used repeatedly.)

for my $req (keys %req_queue) {
  my %reqdata = $req_queue{$req};
}

starts up fine, but, of course, fails when it executes.  ('Reference found
where even-sized list expected')


for my $req (keys %req_queue) {
  my %reqdata = %$req_queue{$req};
}

gives a compile-time error of 'Global symbol "$req_queue" requires explicit
package name'.  Even though the previous example didn't mind the
$req_queue{$req}.


for my $req (keys %req_queue) {
  my %reqdata = %($req_queue{$req});
}

Adding parentheses makes it a lot mor interesting - 'Scalar found where
operator expected near "%($req_queue" (Missing operator before $req_queue?)',
followed by 'syntax error at ./ttsmon.pl line 108, near "%($req_queue"'


Finally,

for my $req (keys %req_queue) {
  my $reqref = $req_queue{$req};
  my %reqdata = %$reqref;
}

actually works.

On the surface, the second, third, and fourth cases seem like they should all
be identical; all three versions pull a hash reference out of %req_queue,
dereference it, and assign the result to %reqdata.  So why don't the second
and third versions get by the compiler?  Is there a way to accomplish this
without requiring an intermediary scalar ($reqref)?

-- 
"Two words: Windows survives." - Craig Mundie, Microsoft senior strategist
"So does syphillis. Good thing we have penicillin." - Matthew Alton
Geek Code 3.1:  GCS d? s+: a- C++ UL++$ P++>+++ L+++>++++ E- W--(++) N+ o+
!K w---$ O M- V? PS+ PE Y+ PGP t 5++ X+ R++ tv b+ DI++++ D G e* h+ r y+


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

Date: Thu, 14 Dec 2000 18:12:35 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Dereferencing hash within hash
Message-Id: <n48_5.1018$uF3.64677@eagle.america.net>

On Thu, 14 Dec 2000 18:00:10 GMT, Dave Sherohman <esper@news.visi.com> wrote:
>I've got a hash of hashes and it seems to be behaving oddly when I try to
>extract one of the contained hashes...  (Yes, I know I could just use
>$hoh{'key1'}{'key2'}.  But I don't like that construct when the contained
>hash is going to be used repeatedly.)
 ...
>for my $req (keys %req_queue) {
>  my %reqdata = %$req_queue{$req};
>}
>
>gives a compile-time error of 'Global symbol "$req_queue" requires explicit
>package name'.  Even though the previous example didn't mind the
>$req_queue{$req}.

That's because `%$req_queue{$req}' parses as `%{$req_queue}{$req}' and
$req_queue was never declared.  What you wanted was

  `%{ $req_queue{$req} }'

-- 
Garry Williams


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

Date: Thu, 14 Dec 2000 18:29:59 GMT
From: esper@news.visi.com (Dave Sherohman)
Subject: Re: Dereferencing hash within hash
Message-Id: <slrn93i4d7.i2n.esper@pchan.sherohman.org>

On Thu, 14 Dec 2000 18:12:35 GMT, Garry Williams <garry@ifr.zvolve.net> wrote:
> That's because `%$req_queue{$req}' parses as `%{$req_queue}{$req}' and
> $req_queue was never declared.  What you wanted was
> 
>   `%{ $req_queue{$req} }'

That worked; thanks.  So why does this work with {} but not ()?  If the
problem is with the order in which the parser sets symbols to associate with
each other, shouldn't parens override that order?

Although this does answer my standing curiousity about {} being used both for
code blocks and hash keys: hash keys _are_ code blocks.

-- 
"Two words: Windows survives." - Craig Mundie, Microsoft senior strategist
"So does syphillis. Good thing we have penicillin." - Matthew Alton
Geek Code 3.1:  GCS d? s+: a- C++ UL++$ P++>+++ L+++>++++ E- W--(++) N+ o+
!K w---$ O M- V? PS+ PE Y+ PGP t 5++ X+ R++ tv b+ DI++++ D G e* h+ r y+


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

Date: Thu, 14 Dec 2000 16:08:16 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Does comp.lang.perl exist? Yes!
Message-Id: <t3hs3grrgrhr5f@corp.supernews.com>

Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "BUCK" == BUCK NAKED1 <dennis100@webtv.net> writes:

> BUCK> Randall was wrong. Yes, comp.lang.perl does exist. Here's proof of its
> BUCK> existence.

That's proof that some servers carry it, although it split into multiple
groups some time ago.

> It *authoritatively* does not exist, by decree from the group of
> people who have managed Usenet since its beginning in 1979.  That does
> not keep people from posting articles that have *NON-EXISTING*
> newsgroups in their headers.

The reason many news servers still carry the unofficial group is that
many people still post to it. There was supposed to be a transition
period during which comp.lang.perl would operate parallel to the newer
groups, to give people the time to learn of the change and alter their
habits. I think that time has passed.

> It does not exist.  There is no comp.lang.perl newsgroup as of 1995
> mid-year.

I didn't realize it had been that long. Anyway, if people really want
to post to a non-official group, there's alt.perl and alt.perl.sockets
to choose from, since most of the alt. tree is pretty unoficial anyway.

Probably the best solution for anyone who would really like to see the
group comp.lang.perl die would be to answer questions in there with
follow-ups set to the appropriate group. I, personally, have no
interest in the group's existence or inexistence. There is a part of me
that likes the idea of a renegade group, though. ;)

Chris
--
Christopher E. Stith - mischief@motion.net
"If the milk turns out to be sour, I'm not the kind of
pussycat to drink it." -- from "Lock, Stock, and Two Smoking Barrels"


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


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

Date: Thu, 14 Dec 2000 11:51:37 -0600
From: Chris Stith <mischief@motion.net>
Subject: Re: Eliminating unneeded whitespace...
Message-Id: <Pine.LNX.4.21.0012141123590.30441-100000@velma.motion.net>

On Wed, 13 Dec 2000, Jeff Pinyan wrote:

> I ran a better benchmark, and used code blocks instead of strings to be
> eval()ed -- I find I get better results this way.

Thanks for all you suggestions, Jeff, I've found them useful.
I still get differing stats for these functions even using your
code. I've split the lines for people with fixed line widths.

<This should throw away unneeded spaces.>
<This should throw away unneeded spaces.>
<This should throw away unneeded spaces.>
<This should throw away unneeded spaces.>
<This should throw away unneeded spaces.>
Benchmark: running join_split, regex_A_1, regex_A_2,
regex_B_1, regex_B_2, each for at least 10 CPU seconds...
join_split: 10 wallclock secs
  (10.15 usr +  0.00 sys = 10.15 CPU) @ 26461.97/s (n=268589)
regex_A_1:  8 wallclock secs
  (10.01 usr +  0.00 sys = 10.01 CPU) @ 13415.98/s (n=134294)
regex_A_2: 11 wallclock secs
  (10.01 usr +  0.00 sys = 10.01 CPU) @ 11487.51/s (n=114990)
regex_B_1: 11 wallclock secs
  (10.02 usr +  0.00 sys = 10.02 CPU) @ 29729.44/s (n=297889)
regex_B_2: 12 wallclock secs
  (10.28 usr +  0.00 sys = 10.28 CPU) @ 27012.94/s (n=277693)

> The abbreviated results are as follows:
> 
> <This should throw away unneeded spaces.>
> <This should throw away unneeded spaces.>
> <This should throw away unneeded spaces.>
> <This should throw away unneeded spaces.>
> <This should throw away unneeded spaces.>
> 
> Benchmark: running join_split, regex_A_1, regex_A_2, regex_B_1, regex_B_2,
> each for at least 10 CPU seconds...
> join_split:  7112.80/s  (n=74471)
>  regex_A_1:  3177.52/s  (n=32506)
>  regex_A_2:  2984.96/s  (n=30566)
>  regex_B_1:  5044.14/s  (n=51198)
>  regex_B_2:  4991.71/s  (n=50566)
> 
> So in 10 seconds, join_split() got in the most iterations.  The regex_A
> approach was slower than the regex_B approach.
>

So, I should be getting better results, but I still get results
closer between the split/join method and the non-alternating
regex methods. The regex_B aproach is even slightly faster in my
tests, although it wasn't very clsoe in yours.

All of this brings me back to the question of what differences
there may be among versions. This system is running the following:

This is perl, version 5.005_03 built for i386-linux
with 5.005_03's own Benchmark module
on a Pentium 166 with 128 megs of ram and eide hard disks
approx. 8 to 10 megs free on average before and after the benchmark

I wouldn't be surprised to find that there are many speedups
in Perl 5.6.0 where split and join are concerned, but I personally
don't have the time to read p5p and the other related mailing lists.
I consider myself doing well to read 1/4 of this group, 1/2 of
c.l.p.modules, most of c.l.p.announce, and most of c.l.p.moderated
and still get any work done. <LOL>.

Chris
--
Christopher E. Stith - mischief@velma.motion.net
"Even now, five years after the fact, I have no idea what the hell
I was thinking." -- anonymous stranger I overheard while at a 
client's building


 



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

Date: Thu, 14 Dec 2000 18:16:57 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Eliminating unneeded whitespace...
Message-Id: <t3i3kpcs1rgpb2@corp.supernews.com>

Chris Stith <mischief@motion.net> wrote:
> On Wed, 13 Dec 2000, Jeff Pinyan wrote:

Sorry for the stealth CC. It seems i sent the previous post
to both Jeff and the newsgroup and forgot to mention it,
so I'm mentioning it now. 

--
Christopher E. Stith - mischief@velma.motion.net



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

Date: Thu, 14 Dec 2000 13:18:05 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Eliminating unneeded whitespace...
Message-Id: <Pine.GSO.4.21.0012141316560.4213-100000@crusoe.crusoe.net>

[posted & mailed]

On Dec 14, Chris Stith said:

>So, I should be getting better results, but I still get results
>closer between the split/join method and the non-alternating
>regex methods. The regex_B aproach is even slightly faster in my
>tests, although it wasn't very clsoe in yours.

I'm using Perl 5.005_02 to test my code.  I've not done it on 5.6
yet.  There may be slight efficiency boosts there and there between _02
and _03.

-- 
Jeff "japhy" Pinyan     japhy@pobox.com    http://www.pobox.com/~japhy/
CPAN - #1 Perl Resource  (my id:  PINYAN)       http://search.cpan.org/
PerlMonks - An Online Perl Community          http://www.perlmonks.com/
The Perl Archive - Articles, Forums, etc.   http://www.perlarchive.com/



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

Date: Thu, 14 Dec 2000 16:01:18 GMT
From: hroces@my-deja.com
Subject: Re: Help! Problem with file uploads using CGI module
Message-Id: <91aqs8$tt9$1@nnrp1.deja.com>

In article <slrn93di46.3io.efflandt@efflandt.xnet.com>,
  efflandt@xnet.com wrote:
> On Tue, 12 Dec 2000, hroces@my-deja.com <hroces@my-deja.com> wrote:
> >
> >I am trying to create a CGI to upload files from user to my server,
> >using a perl script, but I have a problem, I donīt receive a file
> >handle, and I donīt understand it.I only receive the path of the
file,
> >but no the file handle.
> >The code is the following:
> >
> >#This is the HTML page
> >
> >use CGI;
> >
> >#Constructor
> >
> >$query=new CGI;
> >
> >#Header
> >
> >print $query->header;
> >
> >#Form
> >
> >print $query->start_multipart_form('GET','transferir.cgi');
> >print $query->filefield('uploaded_file','starting value',50,180);
> >print $query->br;
> >print $query->submit('attach','Attach');
> >print $query->endform();
> >
> >
> >
> >#This is the CGI: transferir.cgi
> >
> >use CGI;
> >
> >#Constructor
> >
> >$query=new CGI;
> >
> >#Header
> >
> >print $query->header;
> >
> >#Obtain the info
> >
> >$filename = $query->param('uploaded_file');
> >print $filename;
> >print $query->br;
> >
> >#Is a valid file handle?
> >
> >$fh = $query->upload('uploaded_file');
> >if ($fh eq '')
> >{
> >	print "Undefined";
> >	print $query->br;
> >}
> >else
> >{
> >	print "Defined";
> >	print $query->br;
> >}
> >
> ># Read a text file and print it out
> >
> >while (!eof($filename)) # ĄĄĄ Modified !!!
> >{
> > $linea=<$filename>;
> > print $linea;
> >}
>
> Not sure why you do not get file contents, but the above while loop
only
> prints half of the lines in the file.  How many lines does the file
have?
> If it only has 1 line, this loop would not print anything.
>
> The while (<$filename>) reads one line into $_ (which you discard) and
> then $linea=<$filename>; reads the 2nd line into $linea and prints
it.
> Then the while grabs the 3rd line line (which is discarded) then you
read
> the 4th line into $linea, etc.  So your are only only printing every
other
> line starting with the second line.>
>


 Thanks for your help, I have changed this , but my main problem is the
file handle, I canīt obtain a valid file handle.
 $filename contains the path of the archive, however isnīt a valid file
handle, the while do nothing.

Hugo Roces.



Sent via Deja.com
http://www.deja.com/


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

Date: Thu, 14 Dec 2000 18:24:49 GMT
From: msalerno@my-deja.com
Subject: Re: Hopefully not to difficult a question. Please Help
Message-Id: <91b396$626$1@nnrp1.deja.com>

In article <1rpuivcbd4.fsf@video.bsd.uchicago.edu>,
  John Hunter <jdhunter@nitace.bsd.uchicago.edu> wrote:
> >>>>> "msalerno" == msalerno  <msalerno@my-deja.com> writes:
>
>     >>
>     msalerno> There was absolutely nothing wrong with the proposed
>     msalerno> solution, but, I want to get as much information as
>     msalerno> possible before I consider the script complete.  There
>     msalerno> are many ways to accomplish the same task with perl, and
>     msalerno> I like to get as many opinions as I can.  The
>     msalerno> information supplied by Chris Fedde was perfect, but the
>     msalerno> reason that we all post here is so that we can collect
>     msalerno> as much information as possible, and that is all that I
>     msalerno> am doing.  And since I just got 4+ posts letting me know
>     msalerno> that I cannot modify a field in the passwd file without
>     msalerno> rewriting the entire file, I can focus on that.
>
> Here's another solution.  If assumes colon separated fields in
> /etc/passwd and a shell cp in your path.  The script writes to STDOUT.
> Uncomment line to write to /etc/passwd after testing.
>
> There is a hash of pairs from usernames to encrypted passwords which
> stores the values that need updating.
>
> Good luck,
> John Hunter
>
> #!/usr/local/bin/perl -w
>
> use strict;
> use Shell('cp');
>
> #username passwd pairs
> my %updates = ('jdhunter' => 'passwd1',
> 	       'miriam' => 'passwd2');
>
> #make this whatever you want
> my $backupFile = 'passwd.bak';
> cp('/etc/passwd', $backupFile);  #make a backup
> open(PASSWD, "<$backupFile") || die "can't open /etc/passwd\n";
>
> #uncomment after sufficient testing convinces you the script is ok
> #open(OUTFILE, ">/etc/passwd") || die "Can't write /etc/passwd\n";
> open(OUTFILE, ">-") || die "Can't write to STDOUT\n";
>
> while (<PASSWD>) {
>   my @fields = split /:/;
>   $fields[1] =  $updates{$fields[0]} || $fields[1];
>   print OUTFILE join ':', @fields;
> }
>

I actually just finished working out another way to do it.  I used a
more mundane logic, but I am pretty sure that it will do what I need it
to.  I will go back over it an see what I can improve.  It may not be
the best script but it is a start.

Thanks again,
Matt


# Still need lock file, copy and backup of passwd file -
# but that is no problem. This is just for functionality
#!/usr/bin/perl -w
use strict;
use vars qw($o $user $pword $uid $gid $comment $home $shell);

PASSWD:
print "Enter the user information that you want to search for : ";
chomp(my $search =  <STDIN> );
print "\n";
goto PASSWD unless length($search) > 0;

my $file = '/etc/passwd';
open(INFO, $file);
my @lines = <INFO>;
close(INFO);
my $cnt = 0;

for (my $i= 0; $i < @lines; $i++)
{
        if (lc($lines[$i]) =~ /\Q$search/){
        my($user, $pword, $uid, $gid, $comment, $home, $shell) =
split(/:/, $lines[$i]);
        print "User: $user\tComments: $comment\n";
        $cnt++;
        $o = $i;
        }
}

die "No Users found with current search criteria - \"$search\"\n" if
$cnt < 1;
die "\n$cnt users found who match the search criteria \nPlease refine
your search or look at the above list for the user\n\n" if $cnt > 1;

if ($cnt == 1){
my($user, $pword, $uid, $gid, $comment, $home, $shell) = split(/:/,
$lines[$o]);
$pword = "testing";
my $test = join(':',$user, $pword, $uid, $gid, $comment, $home, $shell);
print $test;
print $o;
$lines[$o] = $test;
open(NP, "> /tmp/passwd");
print NP @lines;
close(NP);
}



Sent via Deja.com
http://www.deja.com/


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

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 5111
**************************************


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