[11017] in Perl-Users-Digest
Perl-Users Digest, Issue: 4617 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 11 10:02:07 1999
Date: Mon, 11 Jan 99 07:00:31 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 11 Jan 1999 Volume: 8 Number: 4617
Today's topics:
$32.00 to order RedHat! <webpages@email.com>
a question for perl gurus (I think) <s.berger@intershop.de>
Re: a question for perl gurus (I think) (Larry Rosler)
AN EASY WAY TO FTP IN PERL? <c-denman@dircon.co.uk>
Re: C code to interpret Perl scripts? (Matthew Bafford)
file date/time-stamp ? <j.w.draijer@amc.uva.nl>
Re: How can I compare two arrays? <mymail@nospam.com>
Re: How can I compare two arrays? (Larry Rosler)
how can I redirect the standard input to a file? <wedeking@msw0.attnet.or.jp>
Re: how to greb whole words only? <vpatricio@abrantina.pt>
Re: how to greb whole words only? (Larry Rosler)
Re: how to greb whole words only? (Tad McClellan)
Re: inlclude html in mail thru perl <kimmel00@marvin.informatik.uni-dortmund.de>
Re: internal error: glob failed (Tad McClellan)
Re: internal server error <kimmel00@marvin.informatik.uni-dortmund.de>
Re: Matching binary strings (Bart Lateur)
mog_perl for win95 apache <Stefan.Mueller@ruhr-uni-bochum.de>
Need comforting before Solaris Perl install, <mark.c.hamlin@bt.com>
Re: Optimizing `eval' in a loop <rick.delaney@home.com>
Re: Optimizing `eval' in a loop <hniksic@srce.hr>
Re: Perl and LDAP <kimmel00@marvin.informatik.uni-dortmund.de>
Re: PERL information... (Matthew Bafford)
Re: PERL information... (Tad McClellan)
Re: PERL information... (Matthew Bafford)
Re: Perl within Perl <kimmel00@marvin.informatik.uni-dortmund.de>
Problem compiling perl script <lylooi@ncs.com.sg>
Re: referer address (Matthew Bafford)
Re: rounding (Larry Rosler)
Re: rounding (Matthew Bafford)
Re: rounding (Tad McClellan)
Running Perl under Novell Web Server <k56flex@mail.matav.hu>
Sending SMS messages with perl script ?? <ptrdvds@zeelandnet.nl>
Table formatting from script? <Webmaster@detour.co.uk>
Re: Verify an email address <due@murray.fordham.edu>
Re: Verify an email address <clay@panix.com>
Re: Web Based E-mail service in Perl? <Taco.Bell@rulez.the.net>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 11 Jan 1999 15:16:54 +0100
From: Eirik Johansen <webpages@email.com>
Subject: $32.00 to order RedHat!
Message-Id: <369A07D6.B00869A5@email.com>
Hi!
I'm about to order the RedHat 5.2 distro. I was told that it costs
$49.95 and thought that was a fair price, but they want to charge $32.00
for delivery, which I feel is too much!
I figured that RedHat probably has its office in the US, and I live in
Norway and that's probably why it cost so much. But they had no other
delivery options (menaing cheaper ones...)
Are there any places, say in the UK, that also sell the 5.2 version of
RedHat or is there another way to order it without having to pay so much
for the delivery?
Thanks for your suggestions!
Regards
Eirik Johansen
------------------------------
Date: Mon, 11 Jan 1999 14:11:23 +0100
From: "Stefan Berger" <s.berger@intershop.de>
Subject: a question for perl gurus (I think)
Message-Id: <77ct61$r06@linux1.netconx.de>
Hi,
1. does keys %hash always return the same array (elements in the same order)
2. does keys and values return always arrays (arrays have deterministic
order) that have a "corresponding" order? Means, the third key (in the key
array) has the correct value at the third position (in the value array).
I could not find any hints in the "manual".
Thanks in advance
Stefan Berger
An Example (merging an hash to an existing unnamed hash provided as
reference):
$a = {'a' => 1, 'b' => 2};
%a = ('c' => 3, 'd' => 4);
@$a{keys %a} = values %a;
print map {"$_ => $a->{$_}\n"} keys %$a;
------------------------------
Date: Mon, 11 Jan 1999 05:52:36 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: a question for perl gurus (I think)
Message-Id: <MPG.1103a1f250bf5900989985@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <77ct61$r06@linux1.netconx.de> on Mon, 11 Jan 1999 14:11:23
+0100, Stefan Berger <s.berger@intershop.de> says...
> 1. does keys %hash always return the same array (elements in the same order)
Yes, but why should you care?
> 2. does keys and values return always arrays (arrays have deterministic
> order) that have a "corresponding" order? Means, the third key (in the key
> array) has the correct value at the third position (in the value array).
> I could not find any hints in the "manual".
What "manual" were you reading? Obviously not `perldoc -f keys`, which
contains:
The keys are returned in an apparently random order, but it is the same
order as either the values() or each() function produces (given that the
hash has not been modified).
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 11 Jan 1999 14:02:18 -0000
From: "Chris Denman" <c-denman@dircon.co.uk>
Subject: AN EASY WAY TO FTP IN PERL?
Message-Id: <369a170e.0@norbert.cerbernet.co.uk>
Has anyone got some code that will let me ftp a file?
I have a form, which will upload a file. Then I want to ftp this file to
another server.
Is this easy?
Cheers,
Chris
IA
------------------------------
Date: Mon, 11 Jan 1999 08:58:30 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: C code to interpret Perl scripts?
Message-Id: <MPG.1103cd92ee911cb4989782@news.scescape.net>
In article <adrian-1001992258040001@webgalaxy.com>,
adrian@sequoiarecords.com pounded in the following:
=> I am working on a MUD, and I am looking for C code I can use to script
=> parts of it using perl scripts, all as text files. Is this code
=> commonly/freely available? How much does it cost?
Use the Perl interpreter. Starting information on how to do this is
avaialble in perlembed (perldoc perlembed).
HTH!
--Matthew
------------------------------
Date: Mon, 11 Jan 1999 15:29:58 +0100
From: "J.W.Draijer" <j.w.draijer@amc.uva.nl>
Subject: file date/time-stamp ?
Message-Id: <369A0AE5.51D14EE8@amc.uva.nl>
Hi there,
How can i get a date- and timestamp from a file? I already have a
filehandle.
Thanks for any help.
--
____________________________________________________
J.W. Draijer
Academic Medical Center, Amsterdam (The Netherlands)
Tel. 0031/20 56 666 00
Fax 0031/20 56 690 20
------------------------------
Date: Mon, 11 Jan 1999 07:39:37 -0500
From: JPAH-FLA <mymail@nospam.com>
Subject: Re: How can I compare two arrays?
Message-Id: <3699F108.240BB57D@nospam.com>
You can easily solve this by looping, but as stated (@a) == @b is
ambiguous- you could define it as (length a)=(length b), (each element of
a) is the same as (each corresponding element of b), (each element of a)
(is found in b) and so on...
On another vein however, why is Perl so n-space-ish? It causes all of us
PH's to write the same loops over and over. How's about operators to work
on arrays and such in unity-space. For instance, in APL*, for array A:
(sum of all elements in A): +/A
(has A a non-zero value?): v/A
(generate an array of values 1 thru N): iN
(is A all non-0?) ^/A
(is array A the same as, elementally, B?): ^/A=B
(length of A): pA
(randomly reorder A): A[?ipA]
(make A into an N by M matrix) N M pA
(invert Matrix A) (domino)A
(largest value in A): (ceiling)/A
(smallest) (floor)/A
(concatenate array B to A): A,B
(laminate B below A) A,[1.5]B
(make a new array of the first n-elements of A) N(take)A
(make a new Array by removing the last N elemets of A): N(drop)A
(Make a new array of element N and M): A[M N]
(cross product of A with B): A +.*B
and so on....
Now I know SOME of these are supported in Perl without writing a loop-
reverse and concatenate come to mind. But (a) I can't optimize a loop as
well as the guy who writes the compiler, and (b) I don't want to write
loops for these types of problems over and over again. Make them part of
the language. Its much easier to work outside of loops for the developer,
and one of Larry's design critera was to create a tool to solve problems
quickly. Its MUCH faster to write the constructs above than to loop.
Just my 2c.
* this is NOT a language war- APL is as dead as Latin. Its not a war at
all I hope! I welcome your thoughts..
*******************************************************************
cgi@higherlove.com wrote:
> I've been cracking the books and poring over code trying to figure
> this out, but I can't find ANYTHING!
>
> If I have two arrays
>
> @a which consists of the words "here", "i", and "am"
> @b which consists of the words "do", "i", and "too"
>
> How can I run some type of "for each" routine that compares each item
> in @a to each item in @b and then exit when a match is found?
>
> Thanks!
>
> Lisa
------------------------------
Date: Mon, 11 Jan 1999 05:34:08 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How can I compare two arrays?
Message-Id: <MPG.11039da4d9cbd72a989983@nntp.hpl.hp.com>
In article <MPG.1101e3b03f50d8f98977c@news.scescape.net> on Sat, 9 Jan
1999 22:08:19 -0500, Matthew Bafford <dragons@scescape.net> says...
> In article <36980967.32296180@news.phnx.uswest.net>, cgi@higherlove.com
> pounded in the following:
...
> => How can I run some type of "for each" routine that compares each item
> => in @a to each item in @b and then exit when a match is found?
...
> for my $a ( @a ) {
> for my $b ( @b ) {
> print "Found a match\n" if $a eq $b;
> }
> }
This is patently a quadratic algorithm (O(n**2)), which is OK for 3
elements, but what about 3000?
For a linear algorithm (O(n)), one should use the techniques discussed
in perlfaq4, "How can I tell whether a list or array contains a certain
element?"
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 11 Jan 1999 23:44:16 +0900
From: "Dan Wedeking" <wedeking@msw0.attnet.or.jp>
Subject: how can I redirect the standard input to a file?
Message-Id: <77d2p6$cqo$1@news.misawa.attmil.ne.jp>
I tried the below but it doesn't work? Why? If I take out the open command
and the
file handle "FILE" then it prints what I type to the screen a second time
when I hit the
enter key. Why will this not be directed to append to the file "log.txt"???
open(FILE, ">>log.txt");
while(<STDIN>) {
print FILE;
}
Dan
}
------------------------------
Date: 11 Jan 1999 11:13:11 GMT
From: "Vasco Patricio" <vpatricio@abrantina.pt>
Subject: Re: how to greb whole words only?
Message-Id: <01be3d53$a6dc7c00$370a0a0a@vpatricio>
Try:
@results = grep(/" God "/,@database);
(put a space character before and after the word God)
>V<
------------------------------
Date: Mon, 11 Jan 1999 05:42:01 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: how to greb whole words only?
Message-Id: <MPG.11039f7e201390b3989984@nntp.hpl.hp.com>
In article <369bc586.25032544@news.cyberway.com.sg> on Mon, 11 Jan 1999
09:46:22 GMT, Jason Q. <pigs_can_fly@mindless.com> says...
> Currently, now I'm using:
>
> @results = grep(/"God"/,@database);
>
> but it greps every word containing "God", including Godffrey, Goddamn
> etc...
No, it doesn't. But it would match "God"ffrey, "God"damn etc...
> How do I grep whole words only?
You need to use the word-break assertion \b (see perlre for details):
@results = grep(/\bGod\b/, @database);
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 11 Jan 1999 08:08:56 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: how to greb whole words only?
Message-Id: <ol0d77.mg6.ln@magna.metronet.com>
Jason Q. (pigs_can_fly@mindless.com) wrote:
: Currently, now I'm using:
^^^^^^^^^^^^^^
As opposed to "Currently, some other time"? heh, heh ;-)
: @results = grep(/"God"/,@database);
: but it greps every word containing "God", including Godffrey, Goddamn
: etc...
No it doesn't.
It greps every word containing "God" in double quotes:
"God"ffrey, "God"damn ;-)
I'll assume you didn't mean to type those quotes.
(you should cut/paste code, not try to type it in, else
you'll get comments about your typos instead of about
your real problem...
)
: How do I grep whole words only?
@results = grep(/\bGod\b/, @database);
Unless your definition of "whole words" differs from perl's,
but we can't tell because you didn't tell.
The above, for instance, will match 'God-damn' and
'"God"ffrey' ...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 11 Jan 1999 13:21:04 +0100
From: Sascha Kimmel <kimmel00@marvin.informatik.uni-dortmund.de>
Subject: Re: inlclude html in mail thru perl
Message-Id: <3699ECB0.84DCD6B4@marvin.informatik.uni-dortmund.de>
jasjeetv@pugmarks.com wrote:
>
> Can we include html part in mails thru perl. Similar to the send page option
> used in netscape, where your entire page comes in the mail. Can this be done
> in perl or if you could suggest me some other way.
>
> jasjeet
Hi!
Of course you can do it that way (there's really nothing you couldn't do
with Perl ;).
I would suppose that you have a look at the RFCs regarding MIME and
especially RFC 822.
So you have to attach the HTML content to the mail using MIME.
Have a look at it, I know someone who has made the impossible ;)
Regards,
Sascha Kimmel
webmaster@tricos.com
------------------------------
Date: Mon, 11 Jan 1999 07:40:50 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: internal error: glob failed
Message-Id: <21vc77.mg6.ln@magna.metronet.com>
Danny Aldham (danny@hendrix.postino.com) wrote:
: X-Newsreader: TIN [version 1.2 PL2]
: Below is a very stripped down version of some code I was running that fails
: with an internal error: glob failed at line 7, <_GEN_0> chunk2.
: #!/usr/local/bin/perl -w
: @article= "Newsgroups: comp.os.linux.misc
: Path: news.campus.mci.net ";
Why assign a scalar to an array?
Did you mean to:
1) assign a scalar to a scalar?
$article = "...";
2) assign a scalar to a particular element in the array?
(which is _also_ a scalar)
$article[0] = "...";
3) assign _each line_ to an element in the array?
@article = split /\n/, "...";
: &feed ("") ;
: sub feed () {
: while(<@article>) {
^^^^^^^^^^
You have _asked_ for a glob there.
If you don't want one, don't ask for one ;-)
What do you _want_ to be doing there?
Iterating over the elements in @article?
foreach my $line (@article) {
You shouldn't be accessing a global variable from within your
subroutine either...
: }
: }
: In the production code , @article was a news article that had been pulled
: in,
If @article has already been "pulled in", then why are you
attempting to read in stuff with the input operator (<>)?
(I think <@article> was meant (by you) to be an input operator, but
perl thinks it is a glob() ?
)
: and was going to be worked on. The worrisome problem is that the error
: was kicking to a shell that began executing the @article lines.
Your code is nonsensical and you haven't explained what it is that
you _want_ to be doing, so we cannot really help you fix it...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 11 Jan 1999 13:30:32 +0100
From: Sascha Kimmel <kimmel00@marvin.informatik.uni-dortmund.de>
Subject: Re: internal server error
Message-Id: <3699EEE8.9FB29798@marvin.informatik.uni-dortmund.de>
Madenet wrote:
>
> Anyone can help me ?
>
> I realized a CGI in Perl.
>
> It works with Win 95 and Frontpage Web Server.
>
> After it doesn't work on Apache on BSDI 3.0 Server.
>
> May be a configuration error of server conf files ?
>
> Thanks
Hi!
I hope you didn't transfer your Perl File in binary mode to the BSDI
server, because this would also lead to the problem you describe.
regards,
Sascha Kimmel
------------------------------
Date: Mon, 11 Jan 1999 11:15:28 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Matching binary strings
Message-Id: <3699dc65.13834344@news.skynet.be>
Tim Shaw wrote:
>I'm trying to find a way of avoiding the "double quotish" behaviour of the
>match operation, if possible.
Yes, its possible. See "\Q" in perlre.
if ($value =~ m/\Q$mask\E/) ...
Bart.
------------------------------
Date: Mon, 11 Jan 1999 13:39:39 +0100
From: Stefan Mueller <Stefan.Mueller@ruhr-uni-bochum.de>
Subject: mog_perl for win95 apache
Message-Id: <3699F10B.7B4D@ruhr-uni-bochum.de>
Hi out there!
Is there any procompiled binary for mod_perl
for apache 1.3.3 on a Win95 box.
Thanks for help!
Stefan.
--------------------------------------------
Dipl.-Ing. Stefan Mueller
Ruhr-University Bochum
AG f. num. Meth. i.d. Mechanik und
Simulationstechnik
--------------------------------------------
------------------------------
Date: Mon, 11 Jan 1999 14:38:29 +0000
From: Mark Hamlin <mark.c.hamlin@bt.com>
Subject: Need comforting before Solaris Perl install,
Message-Id: <369A0CE5.E6F28276@bt.com>
Dear All,
I have little unix admin experience and none with Solaris. I think I've covered
all the bases but would like some assurance that I'm going about this the right
way.
My build of perl on the local web server is completely shot, so i'm going to
reinstall it, here's why: I tried to find Perls source/lib directory - the
locations
confirmed with a print -e 'print' "@INC"' did not even exist. When I run
perldoc perldoc
I get the 'can't locate Getopt/Std.pm in @INC at /usr/bin/perldoc line 27
....... Its possible the Perl files on the server in the /bin directory were
simply copied there rather than installed so I only have a bare bones build,
just the 4 files in /bin --
perl, perldoc, perlbug, perl5.004
Definately shot?? Alright then, now about the re-install:
I'm installing on a Sun Sparc box with Solaris 2.6. At Sun's
http://www.sunfreeware.com/ they have the following perl build which is
specifically for a Sparc running 2.6:
"perl-5.005_02-sol26-sparc-local.gz
the Perl system installs in /usr/local. "
The 4 page generic package installation instructions from Sun are very short &
clear, easier than the 25 pages of standard installtion instructions from the
CPAN. Does pkgadd negate all the make & configure steps one needs to carry out
normally. Is it really unzip/pkgadd/& play .???? I've already done the
prelimenaries for pkgadd, theres definately enough space in the critical
locations.
This all seems very simple, have I missed any steps/procedures. Thanks for your
help
Thanks for your help and hopefully a bit of assurance,
Cheers,
Mark Hamlin 01473 646703
Systems Engineer
BT - ACR MCA SIT (don't ask!)
--
___....-----'---'-----....___
=========================================
___'---..._______...---'___
(___) _|_|_|_ (___)
\\____.-'_.---._'-.____//
~~~~'.__'---'__.'~~~~
~~~~~~~
'More speed'
Sisco
Work: mailto:mark.c.hamlin@bt.com
Personal: mailto:mark@dimitrinet.demon.co.uk
Please use you auto reply where possible to distribute to both mailboxes.
------------------------------
Date: Mon, 11 Jan 1999 13:45:30 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Optimizing `eval' in a loop
Message-Id: <369A0247.E216C14C@home.com>
[posted & mailed]
Hrvoje Niksic wrote:
>
> I have a loop that looks like this:
>
> foreach (...) {
> eval ($expr); # Evaluate some user-specified code
> ... some code that doesn't change $expr here ...
> }
>
> Now, $expr is obtained at run-time (not compile-time), but it is
> expected to remain unchanged through the entire foreach loop. Will
> Perl recompile $expr in every pass of the loop?
That depends on which form of eval you are using. From perlfunc:
If the code to be executed doesn't vary, you may use the eval-BLOCK
form to trap run-time errors without incurring the penalty of
recompiling each time.
Modifying Sean McAfee's benchmark, this is what I get:
use Benchmark;
timethese 5000, {
every_time => sub { for (0..20) { eval '$m++' } },
once => sub { $a = eval 'sub { $n++ }'; for (0..20) { &$a } },
block => sub { for (0..20) { eval {$p++} } },
};
print "
$m
$n
$p
";
Benchmark: timing 5000 iterations of block, every_time, once...
block: 0 wallclock secs ( 0.72 usr + 0.00 sys = 0.72 CPU)
every_time: 80 wallclock secs (79.86 usr + 0.00 sys = 79.86 CPU)
once: 7 wallclock secs ( 6.98 usr + 0.00 sys = 6.98 CPU)
105000
105000
105000
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: 11 Jan 1999 14:54:23 +0100
From: Hrvoje Niksic <hniksic@srce.hr>
To: Rick Delaney <rick.delaney@home.com>
Subject: Re: Optimizing `eval' in a loop
Message-Id: <kig1zl15300.fsf@jagor.srce.hr>
Rick Delaney <rick.delaney@home.com> writes:
> > foreach (...) {
> > eval ($expr); # Evaluate some user-specified code
> > ... some code that doesn't change $expr here ...
> > }
> >
> > Now, $expr is obtained at run-time (not compile-time), but it is
> > expected to remain unchanged through the entire foreach loop. Will
> > Perl recompile $expr in every pass of the loop?
>
> That depends on which form of eval you are using.
I use eval as shown above -- I want the contents of $expr to be
evaluated as a Perl expression. However, I know that $expr will not
change during the loop.
> If the code to be executed doesn't vary, you may use the
> eval-BLOCK form to trap run-time errors without incurring the
> penalty of recompiling each time.
I assume that is the "once" benchmark, as shown below:
> once => sub { $a = eval 'sub { $n++ }'; for (0..20) { &$a } },
OK, so to apply the "once" eval flavor in my case, I need to do this
before the loop:
my $compiled = eval 'sub { $expr }';
and, in the loop:
&$compiled;
I think I'll try that; thanks for the tip.
------------------------------
Date: Mon, 11 Jan 1999 13:17:26 +0100
From: Sascha Kimmel <kimmel00@marvin.informatik.uni-dortmund.de>
Subject: Re: Perl and LDAP
Message-Id: <3699EBD6.704D4298@marvin.informatik.uni-dortmund.de>
lt lindley wrote:
>
> Mike Bryan <mab@hrb.com> wrote:
> :>Hello,
>
> Basically, we a Netscape
> :>LDAP server that we need to authenticate username and passwords against
> :>before a user is allowed onto a select group of web pages (a very simple
> :>user validiation).
> :>Is this possible in Perl (i.e. Do I need to learn Perl)?
If you are using Netscape Enterprise Server (3.5 up) which you might
because you use Netscape Directory Server (LDAP) you do not need to do
anything with Perl, because Access control is already built into the
Enterprise server.
If you don't use Netscape Enterprise, then have much fun learning Perl
;)
Regards,
Sascha Kimmel
webmaster@tricos.com
------------------------------
Date: Mon, 11 Jan 1999 08:58:43 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: PERL information...
Message-Id: <MPG.1103cd9c771defec989784@news.scescape.net>
In article <77bqtm$qpo@bgtnsc02.worldnet.att.net>, design@raincloud-
studios.com pounded in the following:
[snip]
=> Although a book, the Camel book "Learning Perl" really seems
=> popular around these parts. I started in other ways, but found
=> it to be the most helpful in getting started right.
=>
=> Chapter 1, A Stroll Through Perl is a good starting point to the
=> basics of the Language, IMO.
=>
=> If you look around, I'm sure it is duplicated on the Web
=> somewhere.
Nope. You got the order mixed up. If you had said
'If you look around, I'm sure someone put it all in a book'
and had been referring to the Perl documentation, you would have been
right.
Almost everything in the camel is in the Perl documentation (ie what
comes with Perl). The reverse can not be said.
=> CT
--Matthew
------------------------------
Date: Mon, 11 Jan 1999 07:27:42 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: PERL information...
Message-Id: <e8uc77.mg6.ln@magna.metronet.com>
Charles R. Thompson (design@raincloud-studios.com) wrote:
: Although a book, the Camel book "Learning Perl" really seems
You have your cites wrong...
"Learning Perl" = Llama (tutorial)
"Programming Perl" = Camel (reference)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 11 Jan 1999 09:32:04 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: PERL information...
Message-Id: <MPG.1103d57259be3fd3989785@news.scescape.net>
In article <MPG.1103cd9c771defec989784@news.scescape.net>,
dragons@scescape.net pounded in the following:
[snip]
As Tad pointed out, you (Charles Thompson) have got your animals mixed
up. I was, of course, referring to the Camel (Programming Perl).
--Matthew
------------------------------
Date: Mon, 11 Jan 1999 13:33:57 +0100
From: Sascha Kimmel <kimmel00@marvin.informatik.uni-dortmund.de>
Subject: Re: Perl within Perl
Message-Id: <3699EFB5.ABEF1351@marvin.informatik.uni-dortmund.de>
backslashxt@yahoo.com wrote:
>
> In article <3697D23C.6ABF927C@snailgem.org>,
> Eugene Sotirescu <eugene@snailgem.org> wrote:
> > backslashxt@yahoo.com wrote:
> > > The call I'm using:
> > > print "<!--\#exec cgi=\"/cgi-bin/topad.cgi\"--> \n"; (Calls banner)
> > >
Hi!
As far as I know a server only parses .html (or sometimes only .phtml
or.shtml) files, so if you let a perl script print that onto the page,
it does not become interpreted by the SSI parser.
Why don't you simply include the source code which implements the banner
in the script which now is writing the ssi line on the page?
Works well at http://www.loversparadise.de !
Regards,
Sascha Kimmel
------------------------------
Date: Mon, 11 Jan 1999 21:27:37 +0800
From: Michelle Looi <lylooi@ncs.com.sg>
Subject: Problem compiling perl script
Message-Id: <3699FC49.5F282ABC@ncs.com.sg>
Hi Everyone,
Currently I have install perl v 5.005_02 in my machine and use it to
help me to compile my perl script into a binary format . I have try to
compile a normal perl script without using "require '...'" (eg require
'cgi-lib.pl') it works fine. However, when I compile a perl script
which use the "require 'cgi-lib.pl' it will give me compilation error.
Can anyone tell me why and I really appreciate it. THANKS A LOT !
ta'
cheer
------------------------------
Date: Mon, 11 Jan 1999 08:58:28 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: referer address
Message-Id: <MPG.1103cd90acb41bc9989781@news.scescape.net>
[Followups set]
In article <77cjmv$8mb$1@nnrp1.dejanews.com>, grey.cloud@usa.net pounded
in the following:
=> Sorry for lame question...
=> Please be so kind as to explain how can I get an URL of the user visited my
=> page in cgi during the session?
=> Thanx.
In an ideal world you could use HTTP_REFERER. Actually, in an ideal
world no browser would be spreading my history, but...
This question is much more on topic for
comp.infosystems.www.authoring.cgi, so followups have been set.
HTH!
--Matthew
------------------------------
Date: Mon, 11 Jan 1999 05:23:56 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: rounding
Message-Id: <MPG.11039b238a7c9443989982@nntp.hpl.hp.com>
In article <369ad08c.10801605@news.skynet.be> on Mon, 11 Jan 1999
10:24:03 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> Tom Cruce wrote:
> >Whats the best way to to round a floating point scalar into an integer ?
> >I've looked around for a function
> >to do this, but I can't seem to find one. Any ideas ?
>
> sprintf
> $number = 8.99;
> $integer = sprintf('%d',$number);
> print "number = $number, integer = $integer\n";
>
> Result:
> number = 8.99, integer = 8
>
> Oh dear.
$number = +8.99;
$integer = int($number + ($number > 0 ? +0.5 : -0.5));
print "number = $number, integer = $integer\n";
Result:
number = 8.99, integer = 9
$number = -8.99;
$integer = int($number + ($number > 0 ? +0.5 : -0.5));
print "number = $number, integer = $integer\n";
Result:
number = -8.99, integer = -9
sprintf('%d", ...) does the same thing as int(...), but why bother with
the slower way?
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 11 Jan 1999 08:58:41 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: rounding
Message-Id: <MPG.1103cd97a67112d0989783@news.scescape.net>
In article <36999C3A.D9DCF4F9@vitesse.com>, tom@vitesse.com pounded in
the following:
=> Whats the best way to to round a floating point scalar into an integer ?
=> I've looked around for a function
=> to do this, but I can't seem to find one. Any ideas ?
s/the best/another/;
perl -we "print sprintf('%.0f', shift)" 8.99
--Matthew
------------------------------
Date: Mon, 11 Jan 1999 07:49:57 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: rounding
Message-Id: <5ivc77.mg6.ln@magna.metronet.com>
Bart Lateur (bart.lateur@skynet.be) wrote:
: Tom Cruce wrote:
: >Whats the best way to to round a floating point scalar into an integer ?
: >I've looked around for a function
: >to do this, but I can't seem to find one. Any ideas ?
: $number = 8.99;
: $integer = sprintf('%d',$number);
: print "number = $number, integer = $integer\n";
: Result:
: number = 8.99, integer = 8
: Oh dear.
$integer = sprintf('%.0f',$number);
Which kinda sorta works for some applications.
For more rigor, see Perl FAQ, part 4:
"Does perl have a round function?
What about ceil() and floor()?
Trig functions?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 11 Jan 1999 12:28:54 +0100
From: "Ketszeri Csaba" <k56flex@mail.matav.hu>
Subject: Running Perl under Novell Web Server
Message-Id: <77cmhu$esq$1@pollux.matav.net>
Hi!
Can anyone help me to migrate my pages to a
Novell web server (from Apache)?
I have only one script, what search a database
and send back the hits, but i just can't run any
script on Novell.
I will get any necessary rights, if you let me
know what ar they (But i won't be supervisor... :-) ).
C ya: Csabii
Ketszeri Csaba, Igal
http://members.tripod.com/~Ketszeri/
------------------------------
Date: Mon, 11 Jan 1999 14:19:29 +0100
From: "Peter Davidse" <ptrdvds@zeelandnet.nl>
Subject: Sending SMS messages with perl script ??
Message-Id: <77cthn$3gu$1@koza.nl.net>
For a hobby project i need to send SMS messages from a linux based
webserver. Does any one know how to send SMS messages with perl.
Short :
Ping -> no reply -> SMS to my GSM
------------------------------
Date: Mon, 11 Jan 1999 13:09:47 -0000
From: "Sovereign Media" <Webmaster@detour.co.uk>
Subject: Table formatting from script?
Message-Id: <77ct9g$jnr$1@news1.cableinet.co.uk>
I am new to perl and so am not reaaaaally very good at it :(
Problem is:
I have a script which pre-pends incoming form data to an .html file. It does
this by reading the .html file and looking for a line which reads <!--Table
Row-->. The script then replaces this line with <!--Table Row--> then a few
more lines of form data - fine so far.
Here is the working part:
================================================
open(ADFILE,"$ClassifiedsDir/$in{'Department'}.html") || die $!;
@main = <ADFILE>;
close(ADFILE);
open(ADFILE,">$ClassifiedsDir/$in{'Department'}.html") || die $!;
foreach $main_line (@main) {
if ($main_line =~ /<!--Table Row-->/) {
print ADFILE "<!--Table Row-->\n";
print ADFILE "<!-- $AdNumber $in{'RealName'} $in{'E-MailAddress'}
$shortdate -->\n";
print ADFILE "<tr><td>\n";
print ADFILE "<i><b>$in{'AdSubject'}</b></i><br>\n";
print ADFILE "<font face=Arial,Helvetica
size=2><b>$in{'Description'}<p>\n";
print ADFILE "<b>Ad No.: </b>$AdNumber - <b>Posted on:
</b>$shortdate<br>\n";
print ADFILE "<b>Reply to: </b>$in{'RealName'} at <a
href=\"mailto:$in{'E-MailAddress'}\">$in{'E-MailAddress'}</a><br>\n";
print ADFILE "<A href=\"$in{'Linkurl'}\">$in{'Linktitle'}</a>";
&ImageRead; #(This is my little addition)
print ADFILE "<p><A href=\"../remove.html\">Remove</a><hr><p>\n";
print ADFILE "</b></font></td></tr>\n<!--end $AdNumber-->\n";
}
else {
print ADFILE "$main_line";
}
}
##########################
sub ImageRead
{
if ($in{'Imgurl'} ne "")
{
print ADFILE "<br><IMG SRC=\"$in{'Imgurl'}\"><br>$in{'Imgtitle'}\n";
}
else
{
print ADFILE "\n";
}
}
########################
================================================
This simply pre-pends the form data to the file in a table format.
<!--Table Row--> (This line overwritten)
<!--21 Me me@home.com --> ($shortdate don't work)
<tr><td>
blah blah blah
</td></tr>
<!--end 21-->
What I want it to do is change the format of the table to be in two columns
i.e.
If $main_line reads <!--Table Row-->
it should print:
<!--Table Data--> (<!--Table Row--> replaced with <!--Table Data-->)
<!--21 Me me@home.com -->
<td>
blah blah
</td></tr>
<!--end 21-->
(Not the best html syntax I know)
But if $main_line reads <!--Table Data-->
Then the next form input should be pre-pended to the file with:
<!--Table Row-->(<!--Table Data--> replaced with <!--Table Row-->)
<!--22 Me me@home.com -->
<tr><td>
blah blah blah
</td>
<!--end 22-->
So we end up with:
(<html>-----<table> tags handled by the .html file)
<html>
<head>
<title></title>
</head>
<body>
<table>
<!--Table Row-->
<!--22 Me me@home.com -->
<tr><td>
blah blah blah
</td>
<!--end 22-->
<!--21 Me me@home.com -->
<td>
blah blah
</td></tr>
<!--end 21-->
(</table>--</html> tags handled by the .html file)
</table>
</body>
</html>
See what I mean?
I have tried various ways of doing 'if - else' or 'if exists()' but it
appears to carry out the the first 'if' and then carry on with the 'else'
thereby overwriting the new form data five or six times or simply wiping the
file clean.
With the if exists() it tried:
$table_line eq "<!--Table Row-->, <!--Table Data-->"
if (exists $table_line{<!--Table Row-->})
{above script with <tr><td>.......</td> tags};}
else
{above script with <td>.......</td></tr> tags}
but that didn't work. Maybe this is the wrong tack entirely, I just tried
that one because it looked reasonable to a newbie!
I'm hoping some of the 'perl gurus' here will have an answer for this one.
------------------------------
Date: 11 Jan 1999 11:24:37 GMT
From: "Allan M. Due" <due@murray.fordham.edu>
Subject: Re: Verify an email address
Message-Id: <77cn1l$m35$0@206.165.165.138>
Martien Verbruggen wrote in message ...
|In article <77b8m6$kd2$0@206.165.165.163>,
| "Allan M. Due" <due@murray.fordham.edu> writes:
|> I can't figure out what the parentheses are for, and the + seems to
|> be in the wrong place. What am I missing?
|
|Which +?
The one I moved in the example.
|
> FAQ version:
|> /^[\w.-]+\@([\w.-]\.)+\w+$/
|
|m{
| ^ # match from start of string
| [\w.-]+ # any 'word' character, literal . or -, one or more times
| \@ # literal @
| ( # group and capture in $1
| [\w.-]\. # any word character, literal . or -
| # followed by a . (+)
| ) # end group and capture
| + # preceding group one or more times (*)
| \w+ # one or more word characters
| $ # match to end of string
|}x
|
|The plus that I believe you think is in the wrong place, is marked
|with (*) above. It is in the correct place.
Correct placing but unnecessary?
|What is missing is a plus
|in the constuct marked with a (+) above. It should read [\w.-]+\.
|>
|> works:
|> /^[\w.-]+\@[\w.-]+\.\w+$/
|
|But this will fail on simple email adresses like foo@bar.bar.com.au,
|because it only matches the [\w.-]\. once. You need to allow it to
|match more than once, by grouping it, and adding a '+'
Umm, it doesn't seem to fail for me. If you will note, in the original post
the + is moved so it is after the [\w.-] and before the \. and it is greedy so
the regexp matches. Because it is greedy we don't need the + after the parens
even if they are included. Including the ():
/^[\w.-]+\@([\w.-]+\.)\w+$/
works if you want $1 to contain bar.bar.com..
I wasn't really trying to identify a better regexp I was just noting that the
one provided doesn't work.
|
|> and do we really need to escape the @ in this case?
|yes
I was just kind of interested because it works fine, with no warnings
under -w and use strict if you don't escape the @. Good practice would seem
to indicate the use of the escape but I was just curious.
Of course, it is early so I reserve the right to be completely wrong in my
remarks <g>.
AmD
------------------------------
Date: Mon, 11 Jan 1999 05:15:52 -0800
From: Clay Irving <clay@panix.com>
Subject: Re: Verify an email address
Message-Id: <3699F988.917E13B7@panix.com>
Richard Zilavec wrote:
> I need a way to verify that an email address is the correct format,
> this is what I came up with but it doesn't completely work:
>
> $ii =~ /^.+\@.+[(.)](com|net|edu|gov|ca|org)/
Read what the FAQ says about checking Email addresses:
http://language.perl.com/newdocs/pod/perlfaq9.html#How_do_I_check_a_valid_mail_addr
--
Clay Irving
clay@panix.com
------------------------------
Date: Mon, 11 Jan 1999 12:46:10 +0100
From: "Taco Bell" <Taco.Bell@rulez.the.net>
Subject: Re: Web Based E-mail service in Perl?
Message-Id: <77co9n$r1f$1@hdxf08.telecom.ptt.nl>
Kijk eens op www.cgi-resources.com, staat wel eentje bij...
Pim Megens wrote in message <778jc4$mqs$1@enterprise.cistron.nl>...
>Hi,
>
>I want to offer my site visitors a free e-mail account like
><name>@<mypage.com>. Does anyone know if there's a Perl script available on
>the www what can do this for me?
>
>I like to hear from you soon!
>
>Kindest regards,
>
>P. Megens
>The Netherlands
>
>
------------------------------
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 4617
**************************************