[17015] in Perl-Users-Digest
Perl-Users Digest, Issue: 4427 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 25 21:05:30 2000
Date: Mon, 25 Sep 2000 18:05:11 -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: <969930311-v9-i4427@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 25 Sep 2000 Volume: 9 Number: 4427
Today's topics:
Re: - For this type of use (see msg), should I favor Pe (Logan Shaw)
Re: - For this type of use (see msg), should I favor Pe (Martien Verbruggen)
Re: /me bangs head agains't brick wall (Martien Verbruggen)
Re: Candidate for the top ten perl mistakes list (Logan Shaw)
Re: Candidate for the top ten perl mistakes list (Martien Verbruggen)
Re: Candidate for the top ten perl mistakes list (Craig Berry)
Re: connecting to MySQL <elephant@squirrelgroup.com>
Re: deamonize (Logan Shaw)
Re: determine where visitors are "living" (Martien Verbruggen)
Re: determine where visitors are "living" (Craig Berry)
Re: determine where visitors are "living" (Craig Berry)
Re: determine where visitors are "living" <godzilla@stomp.stomp.tokyo>
Re: Help required for a win newbie <elephant@squirrelgroup.com>
Help with REGEX for newbie <flsq@home.com>
Re: Help with REGEX for newbie <emschwar@rmi.net>
Re: Help with REGEX for newbie <lr@hpl.hp.com>
Re: Help with REGEX for newbie (Craig Berry)
Re: how do i use localhost <elephant@squirrelgroup.com>
Re: intranet using perl cgi web2200@my-deja.com
Re: Need help on Hash ? <tim@ipac.caltech.edu>
Re: Nested Literals in Perl <anmcguire@ce.mediaone.net>
Re: New to PERL <lr@hpl.hp.com>
parameter passing problem <ssilv@rochester.rr.com>
Re: Pure perl encrypt/decryption? (Abigail)
Re: Pure perl encrypt/decryption? (Logan Shaw)
Re: REQ how to create one line of text (Logan Shaw)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 25 Sep 2000 18:11:33 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: - For this type of use (see msg), should I favor Perl or PHP3?
Message-Id: <8qom35$4gv$1@provolone.cs.utexas.edu>
In article <slrn8sq5c8.jr6.mgjv@martien.heliotrope.home>,
Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>On Sat, 23 Sep 2000 15:16:29 +0200,
> Tony L. Svanstrom <tony@svanstrom.com> wrote:
>> Clay Irving <clay@panix.com> wrote:
>>
>> > On Fri, 22 Sep 2000 23:25:30 -0400, Jon <vemba72@hotmail.com> wrote:
>>
>> > >PS: The server admin told me he had to shut down several sites earlier
>> > >this year because of Perl scripts... too many hits, and every hit ran the
>> > >template-grabbing CGI.
>> >
>> > Sounds like BS.
>>
>> Not really, with CGI you start a new process with each script, that
>> doesn't happen with PHP. [*]
>
>Starting new processes is almost a trivial cost on modern OS's. And
>there is nothing inherent in Perl that forces an OS to spawn a new
>proecess. CGI, yes. But not Perl.
Yes, it's true that Perl doesn't cause a new process to be started.
However, if you use Perl CGIs (which is what the original poster is
proposing to do, I believe), you will incur the cost not only of
fork(), but of perl parsing your script. For a non-trivial Perl script
that uses 5 or 10 modules, this overhead can be something like a
quarter of a CPU-second or even more (depending, of course, on your
CPU). So, the Perl/CGI combination is going to have overhead which
might be significant depending on the traffic the site gets.
PHP, on the other hand, despite being limited and frustrating to use
after using Perl, doesn't incur this overhead, and with PHP 4, it's
pretty darned fast overall too. Of course, the subject says PHP 3, but
I'm guessing that this web hosting system admin who is concerned about
CPU usage will eventually take the plunge.
So, if CPU efficiency is a major concern, Perl/CGI isn't a good
choice. mod_perl is a choice, but it may not be a good one if the
developers aren't sharp enough to do it right. PHP might or might not
be a good choice. If the processing tasks are simple and uncomplicated
and likely to remain that way, PHP might be a good choice.
- Logan
------------------------------
Date: Mon, 25 Sep 2000 23:35:44 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: - For this type of use (see msg), should I favor Perl or PHP3?
Message-Id: <slrn8svoab.m9.mgjv@verbruggen.comdyn.com.au>
On 25 Sep 2000 18:11:33 -0500,
Logan Shaw <logan@cs.utexas.edu> wrote:
>
> Yes, it's true that Perl doesn't cause a new process to be started.
> However, if you use Perl CGIs (which is what the original poster is
[snip]
> PHP, on the other hand, despite being limited and frustrating to use
> after using Perl, doesn't incur this overhead, and with PHP 4, it's
> pretty darned fast overall too. Of course, the subject says PHP 3, but
> I'm guessing that this web hosting system admin who is concerned about
> CPU usage will eventually take the plunge.
There is nothing inherent about PHP that prohibits it being run with
the CGI. In fact, there are many installations who do just that. It is
_often_ run as a server plugin, but Perl can also run that way.
> So, if CPU efficiency is a major concern, Perl/CGI isn't a good
> choice. mod_perl is a choice, but it may not be a good one if the
> developers aren't sharp enough to do it right. PHP might or might not
> be a good choice. If the processing tasks are simple and uncomplicated
> and likely to remain that way, PHP might be a good choice.
Also see other posts in this thread. You are basically repeating
things that I have stated myself as well (are my posts showing up late
on some servers?)
Yes, Perl/CGI is a bad choice. So is PHP/CGI. Compiled C with CGI may
be a perfectly good choice. Or compiled Fortran. The issues involved
are being confused, and things are being linked together that do not
inherently belong together. The CGI generally forces the OS to fork.
The fork is cheap, especially compared to other costs involved. That's
all I said. The whole discussion about Perl on CGI vs PHP as a plugin
is unrelated to that, and a silly comparison to start with. You might
as well ask "What is better? PHP/CGI on a 486, or Perl/CGI on a Sun
E10k with 8 processors?" You are introducing limitations that are not
inherent to the language, and instead of leaving those there, and
trying to answer the question, it's much better to explain that there
are other, better ways.
Now I'm killing this thread. It's beginning to be too repetetive.
Martien
--
Martien Verbruggen |
Interactive Media Division | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd. | cynical. It's perfectly easy to be
NSW, Australia | cynical.
------------------------------
Date: Mon, 25 Sep 2000 23:39:46 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: /me bangs head agains't brick wall
Message-Id: <slrn8svoht.m9.mgjv@verbruggen.comdyn.com.au>
On Mon, 25 Sep 2000 22:19:05 +0100,
CJ Llewellyn <darryl@work-thicker.co.uk> wrote:
>
> Using find is certainly a lot different. I was put off mainly by the
> examples in the cookbook introducing new terms I'd not seen before such as
>
> $saved_size = -s _
Whenever you get into that situation, you should read the perl
documentation.
# perldoc -f -s
explains both the -s operator and the special _ filehandle.
The Cookbook is an excellent book to use when you know Perl, but sort
of need to get an idea on how to accomplish certain tasks. However, it
shouldn't be used to _learn_ the language.
Martien
--
Martien Verbruggen |
Interactive Media Division | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd. | reflects this.
NSW, Australia |
------------------------------
Date: 25 Sep 2000 18:44:37 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Candidate for the top ten perl mistakes list
Message-Id: <8qoo15$4nh$1@provolone.cs.utexas.edu>
In article <MPG.1432e5732eb2f63e98ada4@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>That's why I would never write (as I have seen written here):
>
> push @array => $value; # UGH!!!
>
>The arrow points the wrong way.
Hey, I have a great idea. Let's add to the language an arrow that goes
the other way and acts as a synonmym. How about "<="? That would be a
great addition and you use it when you need to... Oh wait.
Well then, since "<=" and ">=" are opposites, logically what we really
should have is "=<" as the opposite of "=>". So,
push @array =< $value;
Pretty, isn't it?
- Logan, who wants to know when the ":-)" operator will be added[1].
[1] And who is trying to think what its semantics would be if it
were[2].
[2] And who would love -- if it were possible -- to have the square
brackets added as a footnote operator, so that you could hide
confusing details at the bottom of your code in a footnote, just
like people do with technical literature.
[undef] What is that you say? This isn't talk.bizarre? And it isn't
alt.religion.kibology or alt.stupidity either? Nevermind, then.
------------------------------
Date: Tue, 26 Sep 2000 00:10:22 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: Candidate for the top ten perl mistakes list
Message-Id: <slrn8svqb9.m9.mgjv@verbruggen.comdyn.com.au>
On 25 Sep 2000 18:44:37 -0500,
Logan Shaw <logan@cs.utexas.edu> wrote:
>
> - Logan, who wants to know when the ":-)" operator will be added[1].
perl -wpe 'y:-):-}:' file
Martien
PS. yes, I know, it's not an operator.
--
Martien Verbruggen |
Interactive Media Division | If at first you don't succeed,
Commercial Dynamics Pty. Ltd. | destroy all evidence that you tried.
NSW, Australia |
------------------------------
Date: Tue, 26 Sep 2000 00:14:20 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Candidate for the top ten perl mistakes list
Message-Id: <ssvqiskrlsckc1@corp.supernews.com>
Logan Shaw (logan@cs.utexas.edu) wrote:
[snip]
: Well then, since "<=" and ">=" are opposites, logically what we really
: should have is "=<" as the opposite of "=>". So,
:
: push @array =< $value;
:
: Pretty, isn't it?
Both pretty and kinky. I vote yes! But we need to come up with some
additional, non-obvious, and context-dependent ways for it to differ from
=>, in order to give it that Perl feel.
: - Logan, who wants to know when the ":-)" operator will be added[1].
:
: [1] And who is trying to think what its semantics would be if it
: were[2].
I would make it an alternative for the : in the ?: operator. The
semantics would be that in
a ? b :-) c
if a evaluated true, then the value would be b -- *unless* b evaluated
false, in which case it would be c. The idea would be 'a is true? Okay,
pick b -- wait, just kidding! It's c.'
For added fun, if a is false, the process above is reversed -- c, unless c
is also false, in which case b.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Quidquid latine dictum sit, altum viditur."
|
------------------------------
Date: Tue, 26 Sep 2000 11:36:47 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: connecting to MySQL
Message-Id: <MPG.143aa8b636c2a5959897c9@localhost>
Chris wrote ..
>How can I use Perl and CGI to connect to a MySQL Database. I want to be
>able to connect using DBI but the webmaster at the server I signd up on said
>it probably isn't setup. So how do I set it up or what other way is there
>to connect to the database?
type the following at the command prompt for several FAQ answers that
deal with modules (including how to install them in your own directory)
perldoc -q module
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: 25 Sep 2000 19:02:13 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: deamonize
Message-Id: <8qop25$4rr$1@provolone.cs.utexas.edu>
In article <%syy5.245$hs2.11039@news.globetrotter.net>,
Neb <berube@odyssee.net> wrote:
>I can't say actually. I'm hosted by Hypermart.net and I can't find any
>information about their OS version. How can I get it ?
From the shell, just type "uname -sr".
From a CGI, just do:
#! /usr/local/bin/perl -w
use CGI;
$q = new CGI;
print $q->header,
$q->start_html ("OS Version"),
"Your OS version seems to be",
$q->pre (qx{uname -sr}),
"Have a nice day!\n";
Hope that helps.
- Logan
------------------------------
Date: Mon, 25 Sep 2000 22:15:35 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: determine where visitors are "living"
Message-Id: <slrn8svjk2.m9.mgjv@verbruggen.comdyn.com.au>
On Mon, 25 Sep 2000 18:54:16 GMT,
amonotod <amonotod@netscape.net> wrote:
> In article <MPG.1439aacbf1c65b139898a5@news.chello.at>,
> peter pilsl <pilsl@goldfisch.atat.at> wrote:
> > In article <8qnpql$l22$1@nnrp1.deja.com>, kebr@my-deja.com says...
> > > I'm looking for a script that will determine the geographic location
> <snip>
> > You know that the best you can get is the ip-adress of the visitor (or
> <snip>
> > I remember some windows-tools that make some geographical traceroute
> <snip>
> > neotrace.
> I like VisualRoute (multiplatform), http://www.visualroute.com/
\begin[why do I post so many of these lately?]{offtopic}
Software like Visualroute and xtraceroute rely on having accurate
information for a bundle of backbone host IP addresses, and for a
limited number of subnets. They're mainly interested in those
backbones. The total number of IP addresses they can reasonably
reliably tie to coordinates on the map is very small, relatively
speaking. For others they do a reverse name lookup, and 'guess' the
geographical location. For example, anything ending in .au will be
placed at the center of Australia. This could be off by some 2000 km,
and if that's accurate enough, you've just covered a few more IP
addresses. Anything ending in .com, .net, .org or other three letter
top levels cannot be geographically located without an enormous
database that is out of date 2 days after you built it.
Try ibm.net or alter.net. They're everywhere, and ip ranges will not
tell you anything about where they are.
There are proposed extensions for name resolution (RFC1712 and
RFC1876) to make all this possible, but virtually no one actually
implements them.
\end{offtopic}
\begin[for another reason]{offtopic}
> > Maybe some perl-scripts could also grap the visitors timezone and
> > language, so you could get more detailed information.
> I don't think you could do this from the server, but look into some
> client-side javascript. If you want to be able to track it, then you'll
> be looking at some self-posting javascript (is that possible?)
The server doesn't know, and maybe it's possible with JavaScript, but
that's more a discussion for another group.
\end{offtopic}
Martien
--
Martien Verbruggen |
Interactive Media Division | Hi, John here, what's the root
Commercial Dynamics Pty. Ltd. | password?
NSW, Australia |
------------------------------
Date: Mon, 25 Sep 2000 23:28:20 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: determine where visitors are "living"
Message-Id: <ssvnskfopaa18@corp.supernews.com>
Godzilla! (godzilla@stomp.stomp.tokyo) wrote:
: Tom Briles wrote:
: > > Kira, Professional Poker Player
: > > http://la.znet.com/~callgirl/android/poker.cgi
:
: > Ack. I tried a few hands and lost w/A-2-3-4-5.
:
: Although odds of hitting this are near astronomical,
Welcome to QA...the testers will always ferret out two or three bugs on
their first casual use of the product, no matter how astronomical the odds
against their happening, making you look stupid. At the other extreme are
the critical two or three that will slip right through any amount of
testing into release 1.0. :)
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Quidquid latine dictum sit, altum viditur."
|
------------------------------
Date: Mon, 25 Sep 2000 23:48:08 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: determine where visitors are "living"
Message-Id: <ssvp1osi2sj594@corp.supernews.com>
Alan J. Flavell (flavell@mail.cern.ch) wrote:
: On Mon, 25 Sep 2000, Craig Berry wrote:
:
: > This is extremely hard to do.
:
: No Sir. I am confident that on the basis of my headers (and lacking
: any external evidence to the contrary), it is not just "extremely
: hard", it is in fact impossible, for you to determine that I am right
: now in the bedroom of my owner-occupied flat in Glasgow, Scotland.
Right you are; I was speaking loosely. More to the point would be
"impossible to do for all users, extremely hard to do correctly for most
users, and impossible to distinguish the two cases or detect errors
reliably."
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Quidquid latine dictum sit, altum viditur."
|
------------------------------
Date: Mon, 25 Sep 2000 17:00:44 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: determine where visitors are "living"
Message-Id: <39CFE72C.D4774A4E@stomp.stomp.tokyo>
Craig Berry wrote:
> Godzilla! (godzilla@stomp.stomp.tokyo) wrote:
> : Tom Briles wrote:
> : > > Kira, Professional Poker Player
> : > > http://la.znet.com/~callgirl/android/poker.cgi
> : > Ack. I tried a few hands and lost w/A-2-3-4-5.
> : Although odds of hitting this are near astronomical,
> Welcome to QA...the testers will always ferret out two or three bugs on
> their first casual use of the product, no matter how astronomical the odds
> against their happening, making you look stupid. At the other extreme are
> the critical two or three that will slip right through any amount of
> testing into release 1.0. :)
Yeah, this program has been in public use for right at a year.
I am guesstimating over half a million hits so far. This low
ace straight seems the only bug left, or was. Only took a
minute to include this low ace straight. Not so much a bug
really but an airhead oversight on my part. Quite frankly,
I forgot to include this hand in my algorithms.
Fortunately Mr. Berry, there is a difference between being
made to look stupid and being stupid. This difference is
being the latter, would bother me. =)
So far, I beleive this is the first low ace straight hit.
I've only had one Royal Flush hit in a year. This person
won a collection of nude photos of me, online this is,
taken some two decades back when, well, during my pre-big
butt days. Much to my delight, he is long time and close
friend and my nudity is nothing new to this friend. He is
a mathematics professor and a long time social nudist, much
like myself and family. You know how academics are; strange.
* grins *
Godzilla!
--
Robby The Remarkable Robot, Zen Poet
http://la.znet.com/~callgirl/android/zen.cgi
------------------------------
Date: Tue, 26 Sep 2000 12:01:49 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: Help required for a win newbie
Message-Id: <MPG.143aae94eaea608f9897cb@localhost>
padmanab@my-deja.com wrote ..
> I am basically a linux programmer and i wish to know as to how to
>install the Active perl and start coding so that i can start a
>webserver in my Win98 Machine and thereby do coding in PERL- CGI
http://www.activestate.com/
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Mon, 25 Sep 2000 22:56:22 GMT
From: Shawn and Francine <flsq@home.com>
Subject: Help with REGEX for newbie
Message-Id: <39CFD72F.D3650481@home.com>
Hi,
I want to use REGEX to scan a string and find a single digit followed by
any two charecters followed by a white space and delete only that
digit. The snipet I have below deletes everything, digit charecters and
white space. I have tried several variations. Couls someone throw me a
bone?
Thanks in advance.
foreach $cycle (@contents)
{
$cycle =~ s/[0-9]..\s//g;
}
------------------------------
Date: 25 Sep 2000 17:17:34 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Help with REGEX for newbie
Message-Id: <xkfzokwf4ds.fsf@valdemar.cos.agilent.com>
Shawn and Francine <flsq@home.com> writes:
> I want to use REGEX to scan a string and find a single digit followed by
> any two charecters followed by a white space and delete only that
> digit. The snipet I have below deletes everything, digit charecters and
> white space. I have tried several variations. Couls someone throw me a
> bone?
Sure. Let's read your regex, shall we?
> foreach $cycle (@contents)
> {
> $cycle =~ s/[0-9]..\s//g;
This says, "find a digit, followed by two characters, followed by
some whitespace, and replace it with the empty string". What you want to
do is replace it with the two characters and the whitespace, no? So you
group them with '()', and in the replacement, you use the appropriate
$<digit> variable. See 'perldoc perlre', search for "parentheses".
> }
-=Eric
--
On two occasions I have been asked [by members of Parliament!], `Pray,
Mr. Babbage, if you put into the machine wrong figures, will the right
answers come out?' I am not able rightly to apprehend the kind of
confusion of ideas that could provoke such a question.--Charles Babbage
------------------------------
Date: Mon, 25 Sep 2000 16:18:42 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Help with REGEX for newbie
Message-Id: <MPG.14397d2952c998a798adc5@nntp.hpl.hp.com>
In article <39CFD72F.D3650481@home.com> on Mon, 25 Sep 2000 22:56:22
GMT, Shawn and Francine <flsq@home.com> says...
> Hi,
Hi.
> I want to use REGEX to scan a string and find a single digit followed by
> any two charecters followed by a white space and delete only that
> digit. The snipet I have below deletes everything, digit charecters and
> white space. I have tried several variations. Couls someone throw me a
> bone?
We usually throw fish around here.
> Thanks in advance.
You're welcome in advance.
> foreach $cycle (@contents)
> {
> $cycle =~ s/[0-9]..\s//g;
> }
If you really mean 'any characters', you must use the /s modifier to
include newlines. Here is a little fish:
s/[0-9](..\s)/$1/gs;
Here's a better fish, the graduate version of the entire loop:
s/\d(?=..\s)//gs for @countents;
Here's how to fish for yourself:
perldoc perlre (for the regex syntax and semantics)
perldoc perlop (for the substitution operator)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 25 Sep 2000 23:55:20 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Help with REGEX for newbie
Message-Id: <ssvpf8fq11ke6a@corp.supernews.com>
Shawn and Francine (flsq@home.com) wrote:
: I want to use REGEX to scan a string and find a single digit followed by
: any two charecters followed by a white space and delete only that
: digit. The snipet I have below deletes everything, digit charecters and
: white space. I have tried several variations. Couls someone throw me a
: bone?
s/\d(?=..\s)//s;
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Quidquid latine dictum sit, altum viditur."
|
------------------------------
Date: Tue, 26 Sep 2000 11:40:07 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: how do i use localhost
Message-Id: <MPG.143aa9802a60155e9897ca@localhost>
Chris wrote ..
>Someone told me to use 'localhost' as a way to connect to a database because
>the server i'm on does not have the DBI module installed. They also
>suggested that I could install the DBI module myself. How would I do this
>and where would i get it from. I have the DBI module for windows but the
>server is unix, will it work still?
your questions are answered in the FAQs
perldoc -q module
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Mon, 25 Sep 2000 21:57:04 GMT
From: web2200@my-deja.com
Subject: Re: intranet using perl cgi
Message-Id: <8qohn3$jm8$1@nnrp1.deja.com>
AnyBoard may fit your need.
It has lots of functionality.
see http://netbula.com/anyboard
In article <39b3cc51.836450191@news.ionet.net>,
mag@ionet.net (Maggert) wrote:
> On Mon, 04 Sep 2000 11:07:36 GMT, richard_dobson@my-deja.com wrote:
>
> >Please could someone give me some ideas? I have to come up with some
> >good ideas for a research companies intranet. They would like it to
> >become a vital information resource for the workers, and an
invaluable
> >forum for information interchange. All I can think of really is using
> >a bulletin board or chatgroup/newsgroup kind of setup.
> >Are there any perl cgi scripts around for this, or does anyone have
any
> >impressive ideas for an intranet, using perl maybe?
> >
> Smartworker! smartworker.org
> Not a trivial program!
>
> MP
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 25 Sep 2000 16:33:52 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Need help on Hash ?
Message-Id: <39CFE0E0.729F1B5F@ipac.caltech.edu>
tvn007@my-deja.com wrote:
>
> Hi,
>
> Could someone please help me on this ?
>
> I have two files:
>
> File #1
>
> A3 34
> B33 100
>
> File #2
>
> Station1 A3
> Station2 B33
>
> I would like to have the output as follow:
>
> Station1 34
> Station2 100
If the files are of modest size:
open(my $fh1,"<file1name") or die "file1: $!";
open(my $fh2,"<file2name") or die "file2: $!";
my %file1 = split(" ",join("",<$fh1>));
my %file2 = split(" ",join("",<$fh2>));
print $file1{$file2{Station1}}."\n";
--
-- Tim Conrow tim@ipac.caltech.edu |
------------------------------
Date: Mon, 25 Sep 2000 17:17:10 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: Nested Literals in Perl
Message-Id: <Pine.LNX.4.21.0009251714340.16050-100000@hawk.ce.mediaone.net>
On Mon, 25 Sep 2000, patrick_k6801@my-deja.com quoth:
> Hello NG,
> I am trying to define a nested literal in perl. What is the
> equivalent of the following LISP-code in Perl
>
> (setq x '(1,2,(3,4),5))
>
> When i try $a=\(1,2,\(3,4),5) I receive (1,2,SCALAR(blah),SCALAR
> (blah),5). Other combinations also failed. the natural (1,2,(3,4),5)
> leads to (1,2,3,4,5) since (3,4) is evaluated in "list context".
> Can anybody help me ?
I am not familar with LISP, so I am taking somewhat of a shot in the
dark here... Is this what you want?
#!/usr/bin/perl -w
use strict;
my @test = ( 1, 2, [ 3, 4 ], 5 );
print "@test\n";
print "$test[2]->[0]\n";
print "$test[2]->[1]\n";
__END__
HTH.
anm
--
# Andrew N. McGuire
my $j = [ [ qw+ 4A 75 73 74 20 61 0 +] => [ qw+ 6E 6F 74 68 65 72 0 + ] =>
,,,,,,,,, [ qw+ 20 50 65 72 6C 20 0 +] => [ qw+ 48 61 63 6B 65 72 A + ] ];
;;;;;;;;; print map chr(hex()) => map @$_ => map @$j->[$_-0xA], 0xA .. 0xD
------------------------------
Date: Mon, 25 Sep 2000 15:19:35 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: New to PERL
Message-Id: <MPG.14396f5071531b5498adc1@nntp.hpl.hp.com>
In article <slrn8svgs8.lo9.abigail@alexandra.foad.org> on 25 Sep 2000
21:29:57 GMT, Abigail <abigail@foad.org> says...
> Larry Rosler (lr@hpl.hp.com) wrote on MMDLXXXII September MCMXCIII in
> <URL:news:MPG.1439554e5abf57df98adbf@nntp.hpl.hp.com>:
> && In article <slrn8svaie.lo9.abigail@alexandra.foad.org> on 25 Sep 2000
> && 19:42:18 GMT, Abigail <abigail@foad.org> says...
> && > John D. Spencer (jds@idirect.com) wrote on MMDLXXXII September MCMXCIII
> && > in <URL:news:39CF5277.A09F978F@idirect.com>:
> && > )) I am brand new to PERL and am tryign to use the require command. I
> && >
> && > We see that, as you don't know how it's spelled yet. It's called Perl
> && > (for the language), or perl (for the binary).
> && >
> && > And require is not a command. It's a statement.
> &&
> && Hmmm. I would have sworn it was an operator, though I guess one could
> && also call it a function. But not a statement!
...
> $ perl -wce 'require'
> -e syntax OK
> $
Arrgggh. I was hosed by the C grammar, where semicolon is required as a
statement *terminator*:
statement:
...
expression-statement
...
...
expression-statement:
expression[opt] ;
In Perl, semicolon is a statement *separator*. And require() defaults
to require($_). So the _operator_ C<require> can also be the
_expression_ C<require> and can indeed also be the _statement_
C<require>. Terser and terser.
> HTH. HAND.
Actually, it does help me, and maybe others too! HAND.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 26 Sep 2000 00:50:50 GMT
From: "orassilv" <ssilv@rochester.rr.com>
Subject: parameter passing problem
Message-Id: <KpSz5.30241$O37.4529917@typhoon.nyroc.rr.com>
Environment:
nt4.0,
perl is in my path,
running from a msdos command line.
Have a file called test.pl with the following:
print "Hello world \n";
print "@ARGV \n";
print "First arg: $ARGV[0] \n";
print "Second arg: $ARGV[1] \n";
When I call it with test.pl p1 p2 from the command line I get:
Hello world
First arg:
Second arg:
When I call it with perl test.pl p1 p2 from the command line I get:
Hello world
p1 p2
First arg: p1
Second arg: p2
Why do I need to explicity call test.pl using "perl test.pl p1 p2" in order
to get my parameters passed correctly into test.pl?
Thanks,
orassilv
------------------------------
Date: 25 Sep 2000 22:14:24 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Pure perl encrypt/decryption?
Message-Id: <slrn8svjfj.lo9.abigail@alexandra.foad.org>
Chris Fedde (cfedde@u.i.sl3d.com) wrote on MMDLXXXII September MCMXCIII
in <URL:news:VDPz5.407$W3.188763136@news.frii.net>:
{} In article <slrn8sv071.lo9.abigail@alexandra.foad.org>,
{} Abigail <abigail@foad.org> wrote:
{} >
{} >Why would you want to run a proxy on your webserver?
{} >
{}
{} divert(-1)
{} I've seen several instances of cacheing proxies run in the same
{} box as a webserver. Why? Memoizable dynamic content.
{} divert(0)
Well, beside the facts that that kind of defeats the purpose, and that
such a thing could more easily be build in the server itself, if you
want to use such caching proxies, wouldn't it make more sense to put the
proxy on port 80, and communicate with the webserver over the loopback
interface?
Abigail
--
$=-=4*++$|;{print$"x--$==>"\@\x7Fy~*kde~box*Zoxf*Bkiaox \r"
^
$/x24if!select$,,$,,$,,join+q=.==>$^W=>$|;$=&&redo}sleep$|;
------------------------------
Date: 25 Sep 2000 17:46:16 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Pure perl encrypt/decryption?
Message-Id: <8qokjo$4bq$1@provolone.cs.utexas.edu>
In article <slrn8st4c6.lo9.abigail@alexandra.foad.org>,
Abigail <abigail@foad.org> wrote:
>Logan Shaw (logan@cs.utexas.edu) wrote on MMDLXXXI September MCMXCIII in
><URL:news:8qlvnh$14$1@provolone.cs.utexas.edu>:
>;; In article <slrn8slesj.5fq.abigail@alexandra.foad.org>,
>;; Abigail <abigail@foad.org> wrote:
>;; >&& Logan Shaw wrote:
>;; >&& >If you have CGI access, don't you almost by definition have shell
>;; >&& >access?
>;; >
>;; >Of course, a properly configured host doesn't allow connections to ports
>;; >other than necessary to perform its task, so it might very well be that
>;; >any port other than 80 is firewalled out.
>;;
>;; *Inbound* ports might be disabled, but so what?
>
>That entirely depends on your firewall configuration. For a webserver,
>why should a firewall let any package through bound for a port other
>than 80, regardless who initiated the connection?
Because, for example, that web server might want to send e-mail
messages out to other machines under certain circumstances. In that
case, it might allow outbound TCP connections as long as they're going
to port 25 somewhere. Yes, it's possible that the system admin might
restrict the list of IP addresses to which connections to port 25 are
allowed, but the more rules you make on your firewall, the slower it
gets at filtering stuff (as a general rule), so people don't tend to
make rules very specific.
- Logan
------------------------------
Date: 25 Sep 2000 18:01:16 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: REQ how to create one line of text
Message-Id: <8qolfs$4eu$1@provolone.cs.utexas.edu>
In article <s6cnss87l0sssqorbv890uafg59cl5b3ks@4ax.com>,
SomeWhat <registered12345@hotmail.com> wrote:
>I have a text file which contains the following
>
>
>
>21-9-2000 | dat1 | data2
>data5 | data 6
>data7 | data 8 | data 9 | data 10
>
>21-9-2000 | data1 | data2
>data5 | data 6
>data7 | data 8 | data 9 | data 10
>
>
>How is it possible to put each block on one line.
>Is this possible with perl (preffered and exe file)
The fact that this can be done using special variables notwithstanding,
I'd just parse it like this:
@list_of_things = (); # make sure @list_of_things is an empty array
while (defined ($line = <>)) # read each line in the file
{
if ($line =~ s/\S/) # is there a non-whitespace character?
{
# there is, so this is some data. add it to the
# last string in the array
$list_of_things[$#list_of_things] .= $line;
}
else
{
# this line is empty or is only whitespace, so
# we just saw the end of a section. add a new
# empty string to the array, so that following
# lines will be appended to that string.
push (@list_of_things, '');
}
}
If this works correctly (I haven't tested it), then at the end,
@list_of_things will contain a list of all the stanzas in your file
(including newline characters), and you can then do what you wish with
each string. Probably what you want to do with each string, incidentally,
is to split them up based on either newlines or vertical bars. So,
something like this:
foreach $thing (@list_of_things)
{
@parts = split (m[\||$/], $thing);
}
Hope that helps.
- Logan
------------------------------
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 4427
**************************************