[17151] in Perl-Users-Digest
Perl-Users Digest, Issue: 4563 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 9 18:06:29 2000
Date: Mon, 9 Oct 2000 15:05:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <971129117-v9-i4563@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 9 Oct 2000 Volume: 9 Number: 4563
Today's topics:
"each %hash" evaluated in scalar context? cogswheel@my-deja.com
Re: "each %hash" evaluated in scalar context? <tim@ipac.caltech.edu>
2 questions iamnotananimal@my-deja.com
Re: 2 questions (Clay Irving)
Re: 5.005_03, British Summer Time and caching <steven@ircnet.dk>
Re: apache web server set up problems running perl cgi <gellyfish@gellyfish.com>
Re: Backspace doesn't work? <jdb@wcoil.com>
Re: Best definition of Perl so far in 19100 <gellyfish@gellyfish.com>
Re: Best definition of Perl so far in 19100 <camerond@mail.uca.edu>
Re: Best definition of Perl so far in 19100 <russ_jones@rac.ray.com>
Re: Can I sort a list of hashes by key value? <hartleh1@westat.com>
Re: CGI: How to save upload file by perl? <hartleh1@westat.com>
cookbook: nonforker - why so complex? <knutsenm@my-deja.com>
Re: cookbook: nonforker - why so complex? <knutsenm@my-deja.com>
Re: creating a variable whose name is defined at runtim (Chris Fedde)
debugging a perl process that's already running - HELP. dcaffey@pb.seflin.org
Re: Different Ways to Obtain a Client`s IP ? <gellyfish@gellyfish.com>
DMULTIPLICITY flag <mak@imakhno.freeserve.co.uk>
Re: DMULTIPLICITY flag <anmcguire@ce.mediaone.net>
Re: DMULTIPLICITY flag <mak@imakhno.freeserve.co.uk>
Re: emacs written in perl? (Ben Coleman)
Re: emacs written in perl? (Martien Verbruggen)
Re: factorial function problem (Tim)
Re: factorial function problem <tony_curtis32@yahoo.com>
Re: foreach (@a) {i++; if ($i = even) {$bg = blue};... <news@emkel.co.za>
Help Please <henrywpers@bigfoot.com>
Re: Help Please (Clay Irving)
Re: how to remove unprintable chars with Perl script <cuda71@delanet.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 09 Oct 2000 19:13:33 GMT
From: cogswheel@my-deja.com
Subject: "each %hash" evaluated in scalar context?
Message-Id: <8rt5cn$ev3$1@nnrp1.deja.com>
I have a question about how the 'each' function works.
Page 116 of Programming Perl has the following example:
@common = inter( \%foo, \%bar, \%joe );
sub inter {
my ($k, $href, %seen);
foreach $href (@_) {
while ($k = each %$href) {
$seen{$k}++;
}
}
return grep { $seen{$_} == @_ } keys %seen;
}
Normally, 'each' returns a two-element list consisting of the
(next) key/value pair from a hash. But when it's evaluated in a
scalar context it returns the key, i.e. the first element of the
list.
I've come to expect a list evaluated in scalar context to return
the _last_ element of the list. Is 'each' written to detect which
context it's been called in, and return the key (because that's what
one would ususally want)? Or am I just missing something?
Thanks
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 09 Oct 2000 13:08:29 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: "each %hash" evaluated in scalar context?
Message-Id: <39E225BD.4A78B402@ipac.caltech.edu>
cogswheel@my-deja.com wrote:
>
> Normally, 'each' returns a two-element list consisting of the
> (next) key/value pair from a hash. But when it's evaluated in a
> scalar context it returns the key, i.e. the first element of the
> list.
>
> I've come to expect a list evaluated in scalar context to return
> the _last_ element of the list. Is 'each' written to detect which
> context it's been called in, and return the key (because that's what
> one would ususally want)? Or am I just missing something?
Yes, both builtin and user functions can detect their context. See the
"wantarray" function is perlfunc.
The docs state that it is not safe to assume what the result of a list evaluated
in a scalar context will be. You must read the manual. Most of the time, it does
what you want. The docs are there so you can be sure.
--
-- Tim Conrow tim@ipac.caltech.edu |
------------------------------
Date: Mon, 09 Oct 2000 18:00:31 GMT
From: iamnotananimal@my-deja.com
Subject: 2 questions
Message-Id: <8rt13p$b4i$1@nnrp1.deja.com>
The following is an extract from a script labeled out.pl - It displays
all images from "pic.list" to a browser when run from cgi-bin. (all
images output together at once)
Q. Is there a command I can use to clear the screen before loading the
images as sequential items; giving a slide-show in effect. The commented
lines are just thoughts along this line.
$INPUT_FILE = "/root/apache/Pics/pic.list";
open (INPUT_FILE);
@array = <INPUT_FILE>;
close (INPUT_FILE);
print "Content-type: text/html\n\n";
foreach (@array) {
print "<IMG SRC=http://localhost/cgi-bin/out.pl/$_>\n";
#print "content-clear: text/html" #this is not a real command
#sleep 3 #a pause between slides
}
2./ I read here in an earlier post a script to strip out all lines from
a log-file containing a certain string of characters begining the line
and rewrite the log-file. Could some kind soul re-post that example as
I'm having no luck recreating it myself.
I would like to remove all the local machine server accesses lines from
my logfile before processing with analog.
TIA,
ianaa
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 9 Oct 2000 20:33:52 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: 2 questions
Message-Id: <slrn8u4atg.gi9.clay@panix6.panix.com>
On Mon, 09 Oct 2000 18:00:31 GMT, iamnotananimal@my-deja.com
<iamnotananimal@my-deja.com> wrote:
>The following is an extract from a script labeled out.pl - It displays
>all images from "pic.list" to a browser when run from cgi-bin. (all
>images output together at once)
>Q. Is there a command I can use to clear the screen before loading the
>images as sequential items; giving a slide-show in effect. The commented
>lines are just thoughts along this line.
That's not a Perl-related question.
>$INPUT_FILE = "/root/apache/Pics/pic.list";
>open (INPUT_FILE);
>@array = <INPUT_FILE>;
>close (INPUT_FILE);
>print "Content-type: text/html\n\n";
>foreach (@array) {
>print "<IMG SRC=http://localhost/cgi-bin/out.pl/$_>\n";
>#print "content-clear: text/html" #this is not a real command
>#sleep 3 #a pause between slides
> }
>
>2./ I read here in an earlier post a script to strip out all lines from
>a log-file containing a certain string of characters begining the line
>and rewrite the log-file. Could some kind soul re-post that example as
>I'm having no luck recreating it myself.
>I would like to remove all the local machine server accesses lines from
>my logfile before processing with analog.
Something like this?
#!/usr/local/bin/perl -w
$string_to_replace = "I want to replace this string ";
$input_string = "I want to replace this string at the beginning of the line";
($output_string = $input_string) =~ s/^$string_to_replace//;
print "$input_string\n";
print "$output_string\n";
Result:
I want to replace this string at the beginning of the line
at the beginning of the line
--
Clay Irving <clay@panix.com>
Those who make peaceful revolution impossible will make violent revolution
inevitable.
- John Fitzgerald Kennedy
------------------------------
Date: Mon, 09 Oct 2000 20:10:05 GMT
From: steven <steven@ircnet.dk>
Subject: Re: 5.005_03, British Summer Time and caching
Message-Id: <8rt8mm$huh$1@nnrp1.deja.com>
In article <39ddd826.346518752@news.gov.ab.ca>,
Gordon.Haverland@agric.gov.ab.ca wrote:
> Maybe this helps, I don't know. It is worth what you paid for it
> (nothing :-).
... but I'll thank you regardless :)
--
steven
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 9 Oct 2000 11:52:34 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: apache web server set up problems running perl cgi scripts
Message-Id: <8rs81i$cht$1@orpheus.gellyfish.com>
On Sat, 7 Oct 2000 16:38:27 +0900 Dan and Shelly wrote:
> I found out I had to edit a configuration file to get the apache web server
> to run on my windows me machine.
>
> I set the server name in my configuration file to: 127.0.0.1
>
> Now I can get files in my cgi-bin directory to execute perl scripts only
> using batch files. I have a file in my cgi-bin directory called
> first.bat that has the following command:
>
@echo off
> perl "C:\Program Files\Apache Group\Apache\cgi-bin\first.pl"
>
probably better asked in comp.infosystems.www.servers.ms-windows anyhow
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: 9 Oct 2000 18:31:29 GMT
From: "Josiah" <jdb@wcoil.com>
Subject: Re: Backspace doesn't work?
Message-Id: <8rt2u1$obp$0@206.230.71.18>
NEWIMAGE <cuda71@delanet.com> wrote in message
news:39E20856.E5403D8B@delanet.com...
<snip>
> .profile. Regardless how can I make a destructive backspace work in my
> perl program.
Look at Term::Sample, see the sample() function
in it. It allows for destructive backspace. It is
on CPAN or at
http://www.josiah.countystart.com/modules/get.pl?term-sample
I don't know how well it works over telnet, tho. I havn't
tried that yet.
hth,
--
Josiah Bryan
jdb@wcoil.com
-----------------------------------------------------------------------
Pursuant to US Code, Title 47, Chapter 5, Subchapter II, ¢227,
Any and all nonsolicited commercial E-mail sent to this address
is subject to a download and archival fee in the amount of $500.00 US.
E-Mailing denotes the acceptance of these terms
-----------------------------------------------------------------------
------------------------------
Date: 9 Oct 2000 11:49:16 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Best definition of Perl so far in 19100
Message-Id: <8rs7rc$chf$1@orpheus.gellyfish.com>
On Sun, 08 Oct 2000 14:13:17 -0500 Cameron Dorey wrote:
>
> "There is no path to perl, ... "
>
... You must forge your own.
L Ron Hubbard move over - I've got a new religion coming.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Mon, 09 Oct 2000 14:00:56 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Best definition of Perl so far in 19100
Message-Id: <39E215E8.88130384@mail.uca.edu>
Jonathan Stowe wrote:
>
> On Sun, 08 Oct 2000 14:13:17 -0500 Cameron Dorey wrote:
> >
> > "There is no path to perl, ... "
> >
>
> ... You must forge your own.
>
> L Ron Hubbard move over - I've got a new religion coming.
Perlanetics? Diaperlics (I like this one, sounds so close to diabolic) ?
Cameron
--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu
------------------------------
Date: Mon, 09 Oct 2000 15:50:45 -0500
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: Best definition of Perl so far in 19100
Message-Id: <39E22FA5.F67D03A3@rac.ray.com>
Cameron Dorey wrote:
>
> "5) Whats the path to Perl? There is no path to perl...
The Noble Truth of the Eightfold Path to Perl Enlightenment:
Right View - (The Enlightened One sayeth) Use thou the "-w" option and
the "use strict;' pragma, thus shall you never stray from the noble
path.
Right Resolve - Be thou resolved on renunciation, of freedom from ugly
C- or Fortran- or COBOL-like constructs. Resolve, therefore, to
meditate in Perl, and not to attempt to force Perl to fit some other
false dharma. (There are many paths to the mountain, but only one path
to the top of the mountain. - HH the Dali Lama)
Right Speech - Say not "perl" when thou mean'st "Perl" and know thou
the difference, for many are the demons that shall visit upon you
should thou err in this wise. And whatever you do, don't say "PERL!"
Right Action - Use thou not "tr///" when thou mean'st "s///" and
likewise the reverse. Use not recursion when a loop will do. Use
foreach when you mean foreach. Use $_, that's what it's there for.
Reinvent thou not the wheel.
Right Livelihood - Post thou not job offers to comp.lang.perl.misc,
nay, indeed, in any place where employment is not the topic, lest the
terrifying and wrathful demon David H. Adler hop on thy case.
Right Effort - R thou the FM.
Right Mindfulness - Remain mindful that thou art not the only
supplicant in the world and that some other poor schlub may be called
upon to maintain your code, or that even you may wish to remember what
the hell you did last week. Remain also mindful that while thou might
know a lot, you probably don't know it all, and we were all novitiates
at one time.
Right Concentration - There is a case where a monk enters and remains
in the jhana: the rapture and pleasure born from withdrawal,
composure, unification of awareness, mindfulness, alertness. But blink
once and someone will change the language on you.
--
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747
Quae narravi, nullo modo negabo. - Catullus
------------------------------
Date: Mon, 09 Oct 2000 15:46:16 -0400
From: hartley_h <hartleh1@westat.com>
Subject: Re: Can I sort a list of hashes by key value?
Message-Id: <39E22088.EF5484EE@westat.com>
"Randal L. Schwartz" wrote:
>
> [1] Give a man a fish, he eats for a day. Teach a man to fish, he
> eats for a lifetime.
>
> Give a man a fire, he's warm for a day. Set a man on fire, he's
> warm for the rest of his life.
Sell a man a fish, he eats for a day. Teach a man to fish, you've lost
a customer.
--
Henry Hartley
------------------------------
Date: Mon, 09 Oct 2000 15:40:21 -0400
From: hartley_h <hartleh1@westat.com>
Subject: Re: CGI: How to save upload file by perl?
Message-Id: <39E21F25.D1D47D90@westat.com>
i0519@my-deja.com wrote:
>
> I mean that I have a html file, which have a form to collect local file.
> When summited, I want to upload the file. And not by ftp, maybe by
> http 's post method, I think.
>
Read the document at
<http://stein.cshl.org/WWW/software/CGI/cgi_docs.html>. If you still
don't know what to do then, ask a more specific question.
--
Henry Hartley
------------------------------
Date: Mon, 09 Oct 2000 21:34:36 GMT
From: Mark Knutsen <knutsenm@my-deja.com>
Subject: cookbook: nonforker - why so complex?
Message-Id: <8rtdlc$m7b$1@nnrp1.deja.com>
I'm trying to understand the code for a multiplexing server without
forking, section 17.13 (p.628) of the Cookbook. It seems a bit overly
complicated to me in the sense that it moves complete client requests
from an input buffer to a separate hash:
while ($inbuffer{$client} =~ s/(.*\n)//) {
push( @{$ready{$client}}, $1 );
}
just so it can process them all later in the while(1) loop:
foreach $client (keys %ready) {
handle($client);
}
And to get 'keys %ready' to work properly, it has to use Tie::RefHash.
Why not just handle($1) immediately above, and avoid the use of %ready
and Tie::RefHash completely? It can't be a timing issue; this is just
one big while() loop.
--Mark Knutsen
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 09 Oct 2000 21:52:44 GMT
From: Mark Knutsen <knutsenm@my-deja.com>
Subject: Re: cookbook: nonforker - why so complex?
Message-Id: <8rtena$n56$1@nnrp1.deja.com>
Small oops below: handle($1) is the wrong syntax. The handle()
subroutine would need a trivial rewrite, but you get my point.
In article <8rtdlc$m7b$1@nnrp1.deja.com>,
Mark Knutsen <knutsenm@my-deja.com> wrote:
> I'm trying to understand the code for a multiplexing server without
> forking, section 17.13 (p.628) of the Cookbook. It seems a bit overly
> complicated to me in the sense that it moves complete client requests
> from an input buffer to a separate hash:
>
> while ($inbuffer{$client} =~ s/(.*\n)//) {
> push( @{$ready{$client}}, $1 );
> }
>
> just so it can process them all later in the while(1) loop:
>
> foreach $client (keys %ready) {
> handle($client);
> }
>
> And to get 'keys %ready' to work properly, it has to use Tie::RefHash.
>
> Why not just handle($1) immediately above, and avoid the use of %ready
> and Tie::RefHash completely? It can't be a timing issue; this is just
> one big while() loop.
>
> --Mark Knutsen
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 09 Oct 2000 18:16:31 GMT
From: cfedde@u.i.sl3d.com (Chris Fedde)
Subject: Re: creating a variable whose name is defined at runtime?!?
Message-Id: <3YnE5.35$7J6.170977792@news.frii.net>
In article <39e1f46b.46ba$2e0@news.op.net>,
Mark-Jason Dominus <mjd@plover.com> wrote:
>In article <8rsrfg$iglrf$1@ID-23826.news.cis.dfn.de>,
>Ralf Siedow <replynews@bigfoot.com> wrote:
>>I want to create a variable whose name I actually don't know.
>
>The most reliable solution is to use a hash:
>
> $value{$var} = 37;
> print $value{$var};
>
>If $var = "test", this creates the variable $value{test}.
>
Mark-Jason's answer is right on the mark. but I think that a little
elaboration could be useful to the novice. Please don't take this
as a comment on Mr. Siedow's experience. Maybe this elaboration
could be of some use.
Perl makes it possible to create variables at run time. Here is
one approach to doing that:
#!/usr/bin/perl -l
$var = 'test';
eval "\$$var = 37";
print "\$test = $test";
But what good does that do you? Well in some cases it is just
fine. You may know the names of the variables at programming time.
For example, CGI.pm lets you import the request parameters as
variables into a namespace of your choosing. But that is not the
usual case. Say for example the names come from some external data
source:
#!/usr/bin/perl
# /usr/share/misc/flowers on FreeBSD contains "flowername:meaning\n"
open(F, "/usr/share/misc/flowers") or
die "couldn't open data file: $!";
while(<F>)
{
next if (/^#/ or /^\s+$/);
($name, $meaning) = split(/:/);
$name =~ s/[\s,]+/_/g;
eval qq{\$$name = "$meaning"};
}
print "\$Tulip_red = $Tulip_red";
The problem here is that there is no way to find the names of the
flowers without resorting to medium level magic (package namespace
hashes and such.) We can't list the names of the flowers, nether
can we search for particular flower names or meanings. Using a hash
solves this:
#!/usr/bin/perl
open(F, "/usr/share/misc/flowers") or
die "couldn't open data file: $!";
while(<F>)
{
next if (/^#/ or /^\s+$/);
chomp;
($name, $meaning) = split(/:/);
$flower{$name} = $meaning;
}
print "\$flower{$_} = $flower{$_}\n" for (sort keys %flower);
Now your program has access to the names of the flowers and to
their meanings. You now have what programmers call a "data structure"
that allows you to access and traverse the names of flowers and
their meanings. For most purposes this is much more useful than
just pushing variables into the namespace.
In farness this could be done through some kind of encoding of the
variable names and searching in the namespace hash. At best that
would mulate the behavior provided by the hash at a high cost to
clarity and efficiency.
After writing this up it seems to me that Mark-Jason's answer said
said it all anyway. Oh well, guess that I'll post it anyway ;-)
Good Luck
chris
--
This space intentionally left blank
------------------------------
Date: Mon, 09 Oct 2000 19:44:55 GMT
From: dcaffey@pb.seflin.org
To: domcaf@aent.com
Subject: debugging a perl process that's already running - HELP...
Message-Id: <8rt77l$ggs$1@nnrp1.deja.com>
To all you PERL gurus out:
I'd like to be able to debug a perl process that's already running
that's not owned by me on a UNIX system. I'm on the sudo list so
attaching to a process that I don't own is not a problem. What is a
problem is that in all the documentation that I've read on the perl
debugger there is no discussion/description of how to attach to/debug a
perl process that's already running. The docs that I've read
include "http://www.perl.com/pub/doc/manual/html/pod/perldebug.html"
and an excerpt from the docs:
"In Perl, the debugger is not a separate program as it usually is in
the typical compiled environment. Instead, the -d flag tells the
compiler to insert source information into the parse trees it's about
to hand off to the interpreter. .... Then when the interpreter starts
up, it preloads a Perl library file containing the debugger itself. "
Makes me inclined to believe that what I'd like to do is not currently
possible.
If what I'd like to do is possible and you've done it could you send me
an email with the particulars of how you did it when you post your
response back to the newsgroups.
Thanks,
Dom
P.S.: I'm using perl, version 5.004_01 for HPUX.
--
+----------------------
|Dominic Caffey
|dcaffey@pb.seflin.org
+----------------------
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 9 Oct 2000 11:32:24 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Different Ways to Obtain a Client`s IP ?
Message-Id: <8rs6ro$cgh$1@orpheus.gellyfish.com>
On Sat, 7 Oct 2000 18:02:16 +1100 Martien Verbruggen wrote:
> On Sat, 7 Oct 2000 07:17:23 +0100,
> Philip Lancefield <dontmail@me.com> wrote:
>> Here`s my question. I want to record the IP addresses of people visiting my
>> site. The simple way to do this is to use the environmental variables the
>> client browser provides. However, there may be occasions when a visitor is
>> using a proxy to disguise their real IP address. For security reasons it is
>> important that I obtain the real IP address of the person. I know that, for
>> instance, you can obtain the real IP of a user who is using a proxy for HTTP
>> and FTP by connecting to the security port. So what I would like the answer
>> to is -
>
> You seem to be confused, about many things. There are much simpler ways
> to obtain the IP address. There are many reasons that proxy servers are
> used, hiding 'real' IP addresses probably being at the bottom of that
> list. You can't base security on IP addresses, unless you manage the IP
> addresses that you want to base the security on. You cannot obtain the
> real IP address of anyone on the Web, simply because there is no such
> thing as a real IP address. Even if there was, you wouldn't be able to
> get it. Even if you could, many IP addresses of people using proxies
> won't make any sense to you, because they're internal addresses.
>
Just for the record it might be added that the client host might not
have an *IP* address at all as the proxy could be a gateway to some
totally different networking protocol.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Mon, 9 Oct 2000 20:27:18 +0100
From: "Makhno" <mak@imakhno.freeserve.co.uk>
Subject: DMULTIPLICITY flag
Message-Id: <8rt671$aqp$2@newsg3.svr.pol.co.uk>
I've been told to compile Perl with -DMULTIPLICITY.
Not being entirely sure what this means, but still able to compile Perl, I
tried
./Configure -D -D -DMULTIPLICITY
Then the usual make etc.
I don't think this worked however. Can someone suggest to me how I compile
Perl with the -DMULTIPLICITY flag?
(I would ask 'where do I put it??' but this might have obvious
reprocussions).
------------------------------
Date: Mon, 9 Oct 2000 15:18:13 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: DMULTIPLICITY flag
Message-Id: <Pine.LNX.4.21.0010091517180.16682-100000@hawk.ce.mediaone.net>
On Mon, 9 Oct 2000, Makhno quoth:
M> I've been told to compile Perl with -DMULTIPLICITY.
M> Not being entirely sure what this means, but still able to compile Perl, I
M> tried
M>
M> ./Configure -D -D -DMULTIPLICITY
M>
M> Then the usual make etc.
M> I don't think this worked however. Can someone suggest to me how I compile
M> Perl with the -DMULTIPLICITY flag?
M>
M> (I would ask 'where do I put it??' but this might have obvious
M> reprocussions).
IIRC, when you run Configure, it asks if you want to compile for
multiplicity, answer yes. But then again, my mind may be playing tricks
on me.
anm
--
perl -wMstrict -e '
$a=[[qw[J u s t]],[qw[A n o t h e r]],[qw[P e r l]],[qw[H a c k e r]]];$.++
;$@=$#$a;$$=[reverse sort map$#$_=>@$a]->[$|];for$](--$...$$){for$}($|..$@)
{$$[$]][$}]=$a->[$}][$]]}}$,=$";$\=$/;print map defined()?$_:$,,@$_ for @$;
'
------------------------------
Date: Mon, 9 Oct 2000 22:16:49 +0100
From: "Makhno" <mak@imakhno.freeserve.co.uk>
Subject: Re: DMULTIPLICITY flag
Message-Id: <8rtcks$2vp$1@news6.svr.pol.co.uk>
>M> ./Configure -D -D -DMULTIPLICITY
>M>
oops...bit of a stutter there...I meant:
./Configure -d -D -DMULTIPLICITY
>IIRC, when you run Configure, it asks if you want to compile for
>multiplicity, answer yes.
Hmmm, I was hoping that I could run through the Configure script with
defaults but just change the single thing.
------------------------------
Date: Mon, 09 Oct 2000 19:35:23 GMT
From: oloryn@mindspring.com (Ben Coleman)
Subject: Re: emacs written in perl?
Message-Id: <39e21dce.425081705@localhost>
On Mon, 09 Oct 2000 16:33:30 GMT, David Steuber
<nospam@david-steuber.com> wrote:
>Brilliantly done. I am utterly
>humbled before the master of all things.
Please do not pin the sarcasmometer that way. Meter movements are a
pain to replace.
Ben
------------------------------
Date: Mon, 09 Oct 2000 22:04:28 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: emacs written in perl?
Message-Id: <slrn8u4g71.2ce.mgjv@verbruggen.comdyn.com.au>
On Mon, 09 Oct 2000 16:20:30 GMT,
Chris Fedde <cfedde@u.i.sl3d.com> wrote:
> In article <slrn8u2vj9.2tj.mgjv@martien.heliotrope.home>,
> Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> >On Sun, 08 Oct 2000 11:56:03 -0500,
> > Mike Eggleston <mikeegg@prodigy.net> wrote:
> >>
> >> I suppose what I'd really prefer is a vi written in perl so that I could
> >> access the underlying interpreter.
> >
> >What about a vi with embedded Perl? http://www.vim.org/
> >
> >I believe there are other vi clones out there that have Perl embedded
> >(nvi?), but I don't have experience with any of those.
> >
>
> I've not seen any real additional utility provided by having an
> embedded interpreter in the VI (nvi) editor. Usually I can get what I
> want by doing bang(!) commands to little text processors written
> in Perl or through at(@) commands. Do you have any examples of
> functionality that has been added to VI through an embedded perl?
> Maybe it is time for me to start using vim.
Me personally? no. But I'm an old fashioned vi user. I use my editor
for editing, not as an OS :)
Other people have reported that they've done useful things with the
perl interpreter in vim, but I can't remember what they were, or even
what sort of work they did. I do remember that some people do indeed
use it to execute perl programs on the current buffer (which also can
be done with the bang, as you say, and I tend to write filters that
way anyway).
The OP asked for perl in an editor, and that's one I know of that has
supported it for a while, so it probably is stable enough. I don't use
it myself, though :)
Martien
--
Martien Verbruggen |
Interactive Media Division | In the fight between you and the
Commercial Dynamics Pty. Ltd. | world, back the world - Franz Kafka
NSW, Australia |
------------------------------
Date: Mon, 09 Oct 2000 19:21:26 GMT
From: SPAM+indigo@dimensional.com (Tim)
Subject: Re: factorial function problem
Message-Id: <8FC886431indigodimcom@166.93.207.145>
lr@hpl.hp.com (Larry Rosler) wrote in
<MPG.1447e6a8d3dc15cf98ae19@nntp.hpl.hp.com>:
>In article <8rkut4$ggk$1@nnrp1.deja.com> on Fri, 06 Oct 2000 16:33:40
>GMT, iamnotananimal@my-deja.com <iamnotananimal@my-deja.com> says...
>You need to hand the subroutine the initial value of $n as an argument.
>That is the critical error in this progam.
>
>> sub factorial {
>> my($n) = shift;
>
>Because you have no initial argument, the '-w' flag will warn you that
>your next use of $n will manipulate an undefined value.
>
>> return(1) if $n == 1;
>
>Just in case $n came in 0 or negative, change the '==' to '<='.
>
>> return($n * factorial($n-1));
}
Just a pet peeve of mine, but why to textbooks always use factorials
as an example for recursion? This is an idiotic way to compute a
a factorial. I remember asking "Why not just use a for loop?", and
thinking recursion was a waste of time. What was worse, a friend
thought this somehow meant recursion was "better", and started using
it *instead* of normal loops.
The point is both of us were mislead becasue this is such a crappy
example.
So do something like this instead:
sub factorial
{
my $n = 1;
$n *= $_ for 2 .. $_[0];
$n;
}
And use Memoize!
-T
------------------------------
Date: 09 Oct 2000 14:52:32 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: factorial function problem
Message-Id: <878zrxvlkv.fsf@limey.hpcc.uh.edu>
>> On Mon, 09 Oct 2000 19:21:26 GMT,
>> SPAM+indigo@dimensional.com (Tim) said:
> Just a pet peeve of mine, but why to textbooks always
> use factorials as an example for recursion? This is an
> idiotic way to compute a a factorial. I remember asking
It's a beautiful way to *state* factorial though. A
factorial is a simple example of what recursion looks
like.
Which is presumably the point that books are trying to
make.
For more information, refer to this article.
hth
t
--
Namaste!
And an "oogabooga" to you too!
-- Homer Simpson
------------------------------
Date: Mon, 9 Oct 2000 20:41:54 +0200
From: "Peter Gibbs" <news@emkel.co.za>
Subject: Re: foreach (@a) {i++; if ($i = even) {$bg = blue};... }
Message-Id: <39e211bb$0$224@hades.is.co.za>
<andrew339@my-deja.com> wrote in message news:8rsii1$u3e$1@nnrp1.deja.com...
> I am printing out the lines of an array. Each line is a <tr> in an
> html table and I want the background color to alternate like a
> checkbook register. This is kind of kludgy and still doesn't work
> correctly. Can someone fix
>
> $i = 0;
> foreach (@match) {
> (@array) = (split /\^/,$_);
> $i++;
> if ($i ne ('0'||'2'||'4'||'6'||'8'||'10'||'12')) {
> $bg = "ffffcc";
> } else {
> $bg = "ccffcc";
> }
> print "<tr>\n<td bgcolor=$bg>\n";
Andrew
Several posters have suggested the modulus operator (%). If, as shown in
your example, you don't use the value of $i for anything else, a bitwise
exclusive or works nicely as a simple toggle:
my $i;
foreach (@match) {
$bg = ($i ^= 1) ? "ffffcc" : "ccffcc";
print "<tr>\n<td bgcolor=$bg>\n";
Regards
Peter Gibbs
EmKel Systems
------------------------------
Date: Mon, 9 Oct 2000 20:44:02 +0200
From: "Henry" <henrywpers@bigfoot.com>
Subject: Help Please
Message-Id: <8rt7d6$269s$1@nnrp01.ops.uunet.co.za>
I hope i am not making a nuisance of myself but I do need some advice
I cant get the following code to work I Got this out of "Sams teach
yourself perl in 24 hours"
If I understand this corretly it should render the following html in a
browser
<html>
<body>
<b>Hello Word</b>
</body>
</html>
Thus Displaying Hello World .
Using this in a dos session actually give me what they say it should but as
soon as I try and use it in a browser (pws or a apache/unix server) it just
fails with an server error if I set allow read in pws it says 404 page not
found, if Idont use allow read it gives me internal error(read acces
forbiden)
#!usr/bin/perl -w
use CGI qw(:standard);
use strict;
print header;
print"<b>Hello World</b>";
------------------------------
Date: 9 Oct 2000 20:38:33 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Help Please
Message-Id: <slrn8u4b69.gi9.clay@panix6.panix.com>
On Mon, 9 Oct 2000 20:44:02 +0200, Henry <henrywpers@bigfoot.com> wrote:
>I hope i am not making a nuisance of myself but I do need some advice
>I cant get the following code to work I Got this out of "Sams teach
>yourself perl in 24 hours"
>If I understand this corretly it should render the following html in a
>browser
>
> <html>
><body>
><b>Hello Word</b>
></body>
></html>
>
>Thus Displaying Hello World .
>
>Using this in a dos session actually give me what they say it should but as
>soon as I try and use it in a browser (pws or a apache/unix server) it just
>fails with an server error if I set allow read in pws it says 404 page not
>found, if Idont use allow read it gives me internal error(read acces
>forbiden)
>
>
>#!usr/bin/perl -w
>use CGI qw(:standard);
>use strict;
>
>print header;
>print"<b>Hello World</b>";
It must be a Web server configuration issue because the code works fine:
Content-Type: text/html
<b>Hello World</b>
--
Clay Irving <clay@panix.com>
The laws of probability, so true in general, so fallacious in particular.
- Edward Gibbon
------------------------------
Date: Mon, 09 Oct 2000 18:59:25 GMT
From: NEWIMAGE <cuda71@delanet.com>
Subject: Re: how to remove unprintable chars with Perl script
Message-Id: <39E21602.BAFE893E@delanet.com>
Here is a program that you use from the command line and pipe the data
into it from the unix command line.
Replace all non-printable characters with a space.
perl -e "s/[^\x20-\x7e]/ /g" -p
or Remove all non-printable characters.
perl -e "s/[^\x20-\x7e]//g" -p
------------------------------
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 4563
**************************************