[12061] in Perl-Users-Digest
Perl-Users Digest, Issue: 5661 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 14 08:07:15 1999
Date: Fri, 14 May 99 05:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 14 May 1999 Volume: 8 Number: 5661
Today's topics:
Re: ASP & PERL <jamespo@N0SPAMyahoo.com>
Re: cgi-lib.pl and uploads <perlguy@technologist.com>
Re: comp.lang.perl.* archive? <gellyfish@gellyfish.com>
Re: Conditional search and replace within a text file <microchip@centuryinter.net>
Re: Cperl mode on NTEmacs help. Also simple newbie perl <plord@hgmp.mrc.ac.uk>
FLOCK and Win 9x <bmhart@mediaone.net>
Re: HASH AND ARRAY armchairmillions@hotmail.com
Hash arrays armchair@my-dejanews.com
Re: Hash arrays (Sam Holden)
How delete space in a string (use of RE) dtillaud@hotmail.com
Re: How delete space in a string (use of RE) (Sam Holden)
Re: pattern matching - confused.... (Andrea L. Spinelli)
Re: pattern matching - confused.... (Bart Lateur)
Perl "constructors" armchair@my-dejanews.com
Re: Perl "constructors" (Sam Holden)
Re: PERLFUNC: eval - catch exceptions or compile code (Bart Lateur)
Re: Perlish linguistics (aka shibbolethim) <tchrist@mox.perl.com>
Re: problem with perl and IIS 4.0 <perlguy@technologist.com>
Signal handlers on win32 - *Trivial* questions <ppa@itmasters.com>
Re: Where is SMPT.pl ? <gellyfish@gellyfish.com>
Re: why won't this cgi script work? (Bart Lateur)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 14 May 1999 10:00:17 +0100
From: James Powell <jamespo@N0SPAMyahoo.com>
Subject: Re: ASP & PERL
Message-Id: <373BE621.123F62A9@N0SPAMyahoo.com>
http://www.PerlScripters.com/
--
-------------------------------------------------------
remove N0SPAM from my email address to reply
-------------------------------------------------------
------------------------------
Date: Fri, 14 May 1999 06:48:08 -0500
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: cgi-lib.pl and uploads
Message-Id: <373C0D78.D580978@technologist.com>
use CGI;
jhenzel@gci-net.com wrote:
>
> Hi
>
> I am posting here partly b/c this is a perl question as well as a cgi
> question. Not sure where the problem is.
>
> I am using cgi-lib.pl to setup a file upload via a website.
> https://bigx.agforbes.arizona.edu/biod/fup.html. The problem I seem
> to be having is that the upload bombs out after about 500k. Same
> limit for both IE and Netscape. My uses will have larger files to
> upload. I have checked the paramters in the library and even cranked
> the maxsize parameter way up and still no luck . Any suggestions
> would be greatly appreciated.
>
> BTW, this page will get password protection once it is finished so
> having a larger file size will not be a problem since only a few
> users will use the capability.
>
> Thanks
>
> Jerry Henzel
------------------------------
Date: 14 May 1999 10:55:39 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: comp.lang.perl.* archive?
Message-Id: <373bf31b@newsread3.dircon.co.uk>
Pavel Kotala <pkotala@logis.cz> wrote:
> Exists any way to explore historical news? I am biginner in discussion
> groups.
>
Deja News at http://www.deja.com is the method most people use - except
for those of use who keep our own news archive ....
/J\
--
Jonathan Stowe <jns@gellyfish.com>
------------------------------
Date: Fri, 14 May 1999 07:15:25 -0400
From: MicroChip <microchip@centuryinter.net>
Subject: Re: Conditional search and replace within a text file
Message-Id: <373C05CD.1D94@centuryinter.net>
Ok, I'll agree with both points made here...
1) readability vs speed. I think I covered that before but yes, Id much
rather be able to follow my code easily than to have to get out a ref
book to read my own code because i wanted speed. (i hope it wouldnt be
quite that bad *G*).
2) A valid point, regex are not always easy to read for anyone besides
the programmer, and sometimes even the programmer (ahem); And as its
been pointed out, there is usually another way to do it. However I use
them because with most of what I do, flexibility is paramount and doing
the job with if/then/else would result in code that looked like BASIC
w/o while-do and for-next (anyone wanna pull data off html pages w/o
regexs and loops?). Personally, I find regex quite friendly and
flexible.
MC
David L. Cassell wrote:
>
> MicroChip wrote:
> > If they havent changed the math rules on me lately, a 30 second
> > difference between the fastest and slowest of those methods, spread over
> > 6 million iterations measures into the microseconds per execution. sorry
> > guys, 10 microseconds isnt worth arguing over unless youre building an
> > operating system, or a real-time interface (both of which would be best
> > done in something other than perl) or an extremely heavily iterative
> > program.
> >
> > Until i get into writing my own operating system or something equally
> > time critical, i'll forfeit a few microseconds and go for the
> > flexible/simple regex approach.
>
> As they say around here, TMTOWTDI.
>
> And as plenty of people have said in other threads, if it doesn't
> get executed multiple times, a microsecond hardly matters. When
> lots of code like this gets put together, times can add up. But
> you're the best judge of that. For my work, usually readability
> takes precedence over speed. Whether regexen constitute readability
> is another argument waiting to happen. :-)
>
> David
> --
> David Cassell, OAO cassell@mail.cor.epa.gov
> Senior computing specialist
> mathematical statistician
--
________________________________
MicroChip Technical Services
backwoods [at] backwoods.org
------------------------------
Date: 14 May 1999 11:48:14 +0100
From: Phillip Lord <plord@hgmp.mrc.ac.uk>
Subject: Re: Cperl mode on NTEmacs help. Also simple newbie perl question
Message-Id: <wkn1z82ahd.fsf@hgmp.mrc.ac.uk>
>>>>> "Eric" == Eric The Read <emschwar@rmi.net> writes:
Eric> Phillip Lord <plord@hgmp.mrc.ac.uk> writes:
>> Im using the latest version of perl on win95. The first version
>> that I wrote was this
Eric> No shebang line (it's still useful on PoB boxen!), no -w, no
Eric> use strict.
Eric> Minus several hundred for those.
Whoops sorry about this. Actually I had those lines (well the
-w not the use strict) but they were before my comments on how I was
going to implement this. Quite long and not worth posting I though!
>> while( $name = readdir( DIR ) ){
Eric> $name just gets set to "bob", if the directory is
Eric> "D:/home/bob".
>> if ( -d $name ){
Eric> And that causes you problems right here. Either chdir() to
Eric> $dir_name, or move the next line above, and test $new_dir, not
Eric> $name.
Okay so that works well and it identifies files well, but it
still doesnt do the recursive call.
>> my $new_dir = $dir_name . "/" . $name;
>>
>> this bit seems to fail because the if ( -d $ name ) never returns
>> true so everything gets identified as a file, and no recursive
>> call takes place. So then I tried...
Eric> It never returns true, because you don't pass it the full path
Eric> name.
Eric> But all this is academic. You don't want to reinvent the
Eric> wheel; you should be using File::Find.
Indeed. I agree it is academic, I am trying to learn perl,
and am trying this one out because it seemed like a nice idea. It's
also along the lines of a tool that I wanted to make, so it seemed a
good place to start. Clearly what I have so far aint much shakes, and
could be done with ls, or find or even some native windows utilities,
but Im trying to get something working which cant be done with
either. I could even write it in one of several other languages I
know, but I thought Id give perl a go. You can see the point in this?
Phil
------------------------------
Date: Fri, 14 May 1999 07:37:50 -0400
From: "Brad & Melissa Hart" <bmhart@mediaone.net>
Subject: FLOCK and Win 9x
Message-Id: <i%T_2.3107$AL5.4723@ndnws01.ne.mediaone.net>
Hey All,
I know that flock won't work in Win 9x (only works in NT, Unix...).
Is there a preferred method for accomplishing the same thing? The
application I am developing realistically shouldn't even need it, but I
would prefer to have a more complete program.
Thanks in advance for any help / advice.
-Brad
bmhart@mediaone.net
------------------------------
Date: Fri, 14 May 1999 11:30:21 GMT
From: armchairmillions@hotmail.com
Subject: Re: HASH AND ARRAY
Message-Id: <7hh1gd$v99$1@nnrp1.deja.com>
In article <7habjt$f5c@news.dns.microsoft.com>,
"J|rgen Exner" <juex@my-dejanews.com> wrote:
>
> <bababozorg@aol.com> wrote in message
news:7ha6cf$l9s$1@nnrp1.deja.com...
> [...]
> > AND ALSO DOES ANY ONE KNOWS HOW TO SORT a HASH?
>
> Please define, what in your opinion is the first and the next element
in a
> hash, i.e. what kind of sequence relation do you intent to use?
>
> Or in other words: Your question is meaningless, because by definition
a
> hash does not have an order.
I don't know about him, but my sequence relation would be a
standard alphabetical ordering of the textual keys.
it would be nice to make:
while ( ($key,$value) = each (%hash) )
{
}
come out in alphabetically sorted key order via some keyword besides
'each' or by setting some variable.
>
> jue
> --
> J|rgen Exner
>
>
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Fri, 14 May 1999 11:17:11 GMT
From: armchair@my-dejanews.com
Subject: Hash arrays
Message-Id: <7hh0nm$uqm$1@nnrp1.deja.com>
How do I find out the number of elements in a hash array?
Thanks
NS
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 14 May 1999 11:42:49 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Hash arrays
Message-Id: <slrn7jo31p.hn5.sholden@pgrad.cs.usyd.edu.au>
On Fri, 14 May 1999 11:17:11 GMT, armchair@my-dejanews.com wrote:
>How do I find out the number of elements in a hash array?
A hash isn't an array...
$number_elements = keys %hash; #
--
Sam
If your language is flexible and forgiving enough, you can prototype
your belief system without too many core dumps.
--Larry Wall
------------------------------
Date: Fri, 14 May 1999 10:06:21 GMT
From: dtillaud@hotmail.com
Subject: How delete space in a string (use of RE)
Message-Id: <7hgsit$s8r$1@nnrp1.deja.com>
Hello,
1)I have some problem to delete all spaces in a string with an RE.
I try many thing like this:
$temp = " hello dede fee ";
$temp =~ / */ /;
I want to obtain "hellodedefee" but nothing happens.
2)I know that RE are very powerful so do you know if it is possible to
obtain a string like this
Before process: $temp = " hello dede fee ";
After process : $temp = "hello dede fee";
Thanks for all.
David Tillaud
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 14 May 1999 10:41:08 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: How delete space in a string (use of RE)
Message-Id: <slrn7jnve4.8t8.sholden@pgrad.cs.usyd.edu.au>
On Fri, 14 May 1999 10:06:21 GMT, dtillaud@hotmail.com wrote:
>Hello,
>
>1)I have some problem to delete all spaces in a string with an RE.
>I try many thing like this:
> $temp = " hello dede fee ";
> $temp =~ / */ /;
>
>I want to obtain "hellodedefee" but nothing happens.
Since your using regular expressions you should read the documentation
on regular expressions. perldoc perlre. It refers you to perlop in the
first paragraph so have a look there. perldoc perlop. There we find :
=item s/PATTERN/REPLACEMENT/egimosx
Searches a string for a pattern, and if found, replaces that pattern
with the replacement text and returns the number of substitutions
made. Otherwise it returns false (specifically, the empty string).
So you want $temp=~s/ */ /; if you want to substitute with your regex.
But I promise you that isn't going to do what you want. It replaces the first
occurance of zero or more concurrent spaces with a single space. You
probably want something like :
$temp=~s/ +//g;
>
>2)I know that RE are very powerful so do you know if it is possible to
>obtain a string like this
>Before process: $temp = " hello dede fee ";
>After process : $temp = "hello dede fee";
You should really check the faq since it tells you two thirds of the solution.
Break it into bits, you want to remove leading spaces, you want to remove
trailing spaces, and you want to compress all remaining sequences of
spaces into one space.
perlfaq4 : How do I strip blank space from the beginning/end of a string?
might be useful reading to help in doing the first two bits. For the last
bit just write the regex to say what you want to do....
ie. Replace (so we use s//) all occurances (so we use /g) of sequences
of one or more spaces (so we use / +/) with one space (so we use / /). Putting
it all together we get :
$temp=~s/ +/ /g;
--
Sam
the Emacs editor is horrible
--Linus Torvalds
------------------------------
Date: Fri, 14 May 1999 09:50:02 GMT
From: aspinelli@ismes.it (Andrea L. Spinelli)
Subject: Re: pattern matching - confused....
Message-Id: <373beede.80234568@news.inet.it>
On Wed, 12 May 1999 09:51:47 +1200, Arran Price
<arranp@datamail.co.nz> wrote:
> s/$CHAR_FROM/$CHAR_TO/g;
I think it is good for you to study Larry's suggestions.
However, as far simplicity is the only concern,
if you just want to substitute single chars,
you could try
tr/$CHAR_FROM/$CHAR_TO/;
which less powerful, but more to-the-point.
See ya
Andrea
--
Andrea Spinelli, Ismes SpA, Via Pastrengo 9, 24068 Seriate BG, Italy
e-mail: aspinelli@ismes.it Phone: +39-035-307209 Fax: +39-035-302999
------------------------------
Date: Fri, 14 May 1999 10:16:55 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: pattern matching - confused....
Message-Id: <373df63c.12569970@news.skynet.be>
Andrea L. Spinelli wrote:
>you could try
> tr/$CHAR_FROM/$CHAR_TO/;
>
>which less powerful, but more to-the-point.
tr/// doesn't interpolate, i.e. You're replacing "$" with "$" etc....
and "F" with "T".
You need
eval "tr/$CHAR_FROM/$CHAR_TO/";
which probably isn't a good idea, speedwise.
Oh, and for the original poster: if you do
$char = "\|";
you loose the backslash. You need it in the final pattern, so do any of
these:
$char = "\\|"; # keeps one backslash
$char = '\|'; # backslash retained for most characters
# Exceptions: '\\' and '\''
$char = quotemeta('|'); # quotes any non-word char
$char = "\Q|"; # idem
or you can mess with '\Q' and '\E' in your final pattern:
$char = "|";
s/\Q$char\E/!!!/g;
Bart.
------------------------------
Date: Fri, 14 May 1999 11:08:25 GMT
From: armchair@my-dejanews.com
Subject: Perl "constructors"
Message-Id: <7hh079$ueo$1@nnrp1.deja.com>
I think it is a questionable "feature" of Perl that the user can define
any name for an object constructor. I think this should be changed. And
an object should be able to consist of more than just a reference.
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 14 May 1999 11:34:37 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl "constructors"
Message-Id: <slrn7jo2id.hn5.sholden@pgrad.cs.usyd.edu.au>
On Fri, 14 May 1999 11:08:25 GMT, armchair@my-dejanews.com wrote:
>I think it is a questionable "feature" of Perl that the user can define
>any name for an object constructor.
I'm sure you do, but perl is in good company in this respect...
After all Eiffel does a similar thing...
>I think this should be changed.
Perl tends to let the programmer so all the enforcing of rules like
that. new() seems to be what most people to use anyway...
>And an object should be able to consist of more than just a reference.
why???? It doesn't gain you anything.
I can't believe I'm replying to this... oh well, you're free to modify
the perl you use to make these things come true...
You just won't be liked much...
--
Sam
Another result of the tyranny of Pascal is that beginners don't use
function pointers.
--Rob Pike
------------------------------
Date: Fri, 14 May 1999 10:06:26 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: PERLFUNC: eval - catch exceptions or compile code
Message-Id: <373cf533.12304463@news.skynet.be>
Randal L. Schwartz wrote:
>Bart> I feel that something is missing from this title. eval() does not only
>Bart> compile code, it *executes* it too.
>
>Oh yeah?
>
>$coderef = eval 'sub { print "This code is not executed, merely compiled" }';
I'll retry.
Look at this code:
for $i (1..10) {
$coderef = sub {
print "This code is not executed, merely compiled"
};
}
If you run this, the sub definition gets compiled once, at startup, and
not then times. But everythime the body of the loop is exectuted, the
(same) value of the coderef is assigned to the variable. The sub is
never run.
the same concept applies to your code snippet:
$coderef = eval
'sub { print "This code is not executed, merely compiled" }';
eval() first compiles the code, and then it executes it. The execution
simply returns the code ref of the anonymous sub.
If it was merely compiled, it would return nothing.
Oh, and this case:
eval 'sub foo { print "Whatever..."; }';
You could say that in this case, you only get the compilation. But let
me remind you that executing such a piece of code actually does nothing.
It's simply skipped.
Fair enough?
Bart.
------------------------------
Date: 14 May 1999 05:46:32 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perlish linguistics (aka shibbolethim)
Message-Id: <373c0d18@cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, vepxistqaosani <fbart@sprynet.com> writes:
:I was wondering why the plural of pragma was not pragmata in the Camel
:book.
% cd camel; grep pragmata ch??
ch02:pragmatic modules. Hint: ignore this and use the pragmata.
ch05:called "pragmatic modules"--or even "pragmata" if you're a classicist.
% cd /usr/src/perl/pod; grep pragmata ch??
perl5005delta.pod:Various pragmata to control behavior of regular expressions.
perlfunc.pod:Perl pragmata. Builtin types have all uppercase names, so to prevent
perlmod.pod:"pragmatic modules" (or even "pragmata" if you're a classicist).
--tom
--
"What interests me is whether God had a choice when he created the world."
- Albert Einstein
------------------------------
Date: Fri, 14 May 1999 06:47:16 -0500
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: problem with perl and IIS 4.0
Message-Id: <373C0D44.A7789EB8@technologist.com>
Go back to ActiveState's site and take a look at the FAQ's. I think FAQ
#6 deals with getting Perl CGI's running on web servers.
Follow ALL of the instructions for your server and you should be up and
running in no time...
Brent
Jason Sova wrote:
>
> I'm trying to get perl to run cgi on an NT server running iis 4.0
> I've installed active perl and it said it made the links to the files
> and I've
> manually add the perl exe to the apps dialog in iis server manage but
> when I try and run the script by typing in the url or running it from a
> small HTML form it just tries to download the .pl file insted of running
> it
>
> Any idea's on this problem???
>
> Jason
------------------------------
Date: Fri, 14 May 1999 12:16:08 +0200
From: "Patrice M.I. Parmentier" <ppa@itmasters.com>
Subject: Signal handlers on win32 - *Trivial* questions
Message-Id: <373BF7E8.138C6AA0@itmasters.com>
Setting signal handlers on win32 systems does not always work:
e.g.:
$SIG{INT} = sub { print "ctrl+C catched.\n"; exit (0); };
While my own compiled perl 5.004 gets the signal, the ActivePerl 5xx
perl ports do not catch the interrupt.
Here are the questions :
- Where can i get (technical) information about signaling with perl on
win32 systems ?
- How to surely catch the signals (are there alternative win32 perl
modules that do the job?) ? (i would want to be able to write a script
that is susceptible to work with almost *any* win32 perl interpreter...)
--
Patrice M.I. PARMENTIER
------------------------------
Date: 14 May 1999 11:00:34 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Where is SMPT.pl ?
Message-Id: <373bf442@newsread3.dircon.co.uk>
Pavel Kotala <pkotala@logis.cz> wrote:
> In which module can I find SMTP.pl? Exists prepared Win32 version?
>
I think that you mean Net::SMTP which is part of libnet bundle, there is
indeed a PPPM package available for this from ActiveState.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
------------------------------
Date: Fri, 14 May 1999 10:38:51 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: why won't this cgi script work?
Message-Id: <373bfc82.14175812@news.skynet.be>
Ala Qumsieh wrote:
>Actually, I didn't mean to say that the chomp() is what's
>missing and that it will make the script work (but I think it seemed
>so, when I look back at it). I just wanted to point out that chomp()
>would be a good idea there, just in case.
I just tried this, warnings enabled.
$_ = "123\n";
print $_+1;
It prints "124", but no warning. So chomp() is never necessary.
Bart.
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 5661
**************************************