[10585] in Perl-Users-Digest
Perl-Users Digest, Issue: 4177 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 9 02:07:20 1998
Date: Sun, 8 Nov 98 23:00:19 -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 Sun, 8 Nov 1998 Volume: 8 Number: 4177
Today's topics:
Re: $a = $a (Sam Holden)
Re: [HELP] Newbie question. (Kevin Reid)
[Q] Bug of socket on NCR? <aqlott@db.csie.ncu.edu.tw>
Any more work on lbnamed, a load-balancing name server? (Clay Shirky)
Re: any simple cookie examples? <rootbeer@teleport.com>
Re: Array Ref Question (Kevin Reid)
Compilation Error? <customer@shaw.wave.ca>
Re: Compilation Error? (Ronald J Kimball)
Effectively replacing browser's history entries <buchanpj@hatespam.citec.qld.gov.au>
Re: Effectively replacing browser's history entries <rootbeer@teleport.com>
Re: file contains files <kprice@cardinal.co.nz>
Re: file contains files (Sam Holden)
Re: HELP w/ Perl & PC Parallel Port <rootbeer@teleport.com>
Re: History of Perl <aravind@genome.wi.mit.edu>
net::nntp <sysop@scbbs.com>
Re: net::nntp (Matthew Bafford)
Re: Not to start a language war but.. <zenin@bawdycaste.org>
Passing reference from C to Perl <perl_writer@hotmail.com>
Re: perl cgi tutorial (NO#!%&SPAM)csu.edu.au (Geoff Deering)
regexp for IP address / host-domain <rickmoy@NOSPAM-yahoo.com>
Re: shift in a list context (Awrobinson)
syslog msg format? <rickmoy@NOSPAM-yahoo.com>
Testing for a number (was: Re: a small question) <rootbeer@teleport.com>
Re: Why doesn't my perl compiler like this expression? <Pap22@erols.com>
Re: Why doesn't my perl compiler like this expression? <dgris@rand.dimensional.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 9 Nov 1998 03:46:37 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: $a = $a
Message-Id: <slrn74cpct.iso.sholden@pgrad.cs.usyd.edu.au>
On Fri, 06 Nov 1998 15:16:35 -0600, James Ludlow <ludlow@us.ibm.com> wrote:
>Todd Smith wrote:
>>
>> if Perl saw this line, would it do some assignment or ignore it like it
>> would a comment?
>>
>> $a = $a;
>
>#! /usr/bin/perl -w
>use Benchmark;
>$a = "itself";
>$b = "";
>timethese (5000000, {
> a => q{
> $a = $a;
> },
> b => q{
> $b = $b;
> },
> comment => q{
> #####
> },
>})
>
>Benchmark: timing 5000000 iterations of a, b, comment...
> a: 2 secs ( 2.37 usr -0.01 sys = 2.36 cpu)
> b: 3 secs ( 2.62 usr 0.03 sys = 2.65 cpu)
> comment: 0 secs ( 0.13 usr -0.05 sys = 0.08 cpu)
> (warning: too few iterations for a reliable count)
>
>It certainly seems to be doing something. What I don't understand is
>why "b" consistently takes more time that "a".
It doesn't for me... I assume you just got lucky.
I stripped the comment part since it's irrevelant and timed a few :
Benchmark: timing 1000000 iterations of a, b...
a: 0 wallclock secs ( 0.73 usr + 0.00 sys = 0.73 CPU)
b: 0 wallclock secs ( 0.70 usr + 0.00 sys = 0.70 CPU)
Benchmark: timing 1000000 iterations of a, b...
a: 1 wallclock secs ( 0.70 usr + -0.01 sys = 0.69 CPU)
b: 1 wallclock secs ( 0.71 usr + 0.01 sys = 0.72 CPU)
Benchmark: timing 1000000 iterations of a, b...
a: 0 wallclock secs ( 0.67 usr + 0.01 sys = 0.68 CPU)
b: 1 wallclock secs ( 0.72 usr + 0.00 sys = 0.72 CPU)
Benchmark: timing 1000000 iterations of a, b...
a: 0 wallclock secs ( 0.73 usr + 0.00 sys = 0.73 CPU)
b: 1 wallclock secs ( 0.69 usr + 0.00 sys = 0.69 CPU)
As you can see the numbers and the order changes from run to run...
And the largest difference in the above was :
0.00000005 seconds for one assignment, small enough to be called
experimental error I think...
--
Sam
Simple rule: include files should never include include files.
--Rob Pike
------------------------------
Date: Sun, 8 Nov 1998 14:49:08 -0500
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: [HELP] Newbie question.
Message-Id: <1di2oqt.1rfif3h99myk2N@slip166-72-108-25.ny.us.ibm.net>
Roger Kenneth Trussell <rtrussell@hps-inc.com> wrote:
> Matthew Bafford wrote in message ...
> >In article <<363B527A.21ACA33D@mail2.intellect.com.tw>>,
>
> >snip...
> >The above example would be much better written as:
> >
> >my %vars;
> >open CFG, 'config' or die "Unable to open 'config', reason: $!\n";
>
>
> I don't mean to be a pain, but isn't the correct syntax for the "or die"
> command for this context is as follows?
>
> open CFG,'config' || die "Unable blah, blah, blah.\n";
>
> Isn't "||" more correct than the word "or"?
No. If you look at the precedence table in perlop, you will see that ||
has higher precedence than a list operator (i.e. 'open'); therefore, the
line is parsed as:
open CFG, ('config' || die "Unable blah, blah, blah.\n");
(which, of course, will never die since 'config' is true.)
Also, 'or die', IMHO, looks nicer and is easier to understand (Open
"config" or die!).
--
Kevin Reid. | Macintosh.
"I'm me." | Think different.
------------------------------
Date: 8 Nov 1998 20:47:46 GMT
From: 84 alumni Orbby S. Arka <aqlott@db.csie.ncu.edu.tw>
Subject: [Q] Bug of socket on NCR?
Message-Id: <72501i$e6i$3@db.csie.ncu.edu.tw>
Hello all,
I'm just trying to upgrade my perl from 5.004 to 5.005_02 to enable the
perlcc and thread stuff. But the script which originally acts well as
a server now failed to bind to the specified port. I just use a netstat
to check if any program is listening to that port, the anwser is negative.
Continuing with my experiment, I tried to run the script on a dec-alpha,
it worked! with perl5.005_02.
Well, is it a known bug for NCR SVR4.0 user that the socket will fail
to bind? Anyone else had came into the same situation? Thanks first.
--
Moment went by, under the sea, dozens of roses bloomed _____ _____
---------------------------------------------------------- | \| _ \
R3-207, Database Lab, Inst of CSIE, NCU, Taiwan, R.O.C | | | _ <
Earving H. Chang (886) 3-4227151 ext 4693 |_____/|_____/
------------------------------
Date: 8 Nov 1998 15:12:40 -0500
From: clays@panix.com (Clay Shirky)
Subject: Any more work on lbnamed, a load-balancing name server?
Message-Id: <724tvo$jf3@panix2.panix.com>
In 94-94, there was some work done on a perl load-balancing
name-server, called 'lbnamed' - reference at
http://www.stanford.edu/~schemers/docs/lbnamed/lbnamed.html
Does anyone else know of this - has it ever been used? Has it been
recently updated?
Thanks
-clay
------------------------------
Date: Sun, 08 Nov 1998 20:50:17 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: any simple cookie examples?
Message-Id: <Pine.GSO.4.02A.9811081249220.14028-100000@user2.teleport.com>
On Sun, 8 Nov 1998, Dan Baker wrote:
> I'm struggling a bit with learning how to use cookies.... does anyone
> have a small example that sets/gets a cookie to post?
Sounds as if you're doing CGI programming. The docs, FAQs, and newsgroups
about CGI programming should be helpful. If you'll be using Perl, the CGI
module may also be useful. Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 8 Nov 1998 14:49:10 -0500
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Array Ref Question
Message-Id: <1di2oxb.1bxsf0ihzlk81N@slip166-72-108-25.ny.us.ibm.net>
Bill Adams <b-i-lla@tqs.antispam.com> wrote:
> Ronald J Kimball wrote:
>
> > Brand Hilton <bhilton@tsg.adc.com> wrote:
> >
> > > my $array_ref = +['1'];
> > > anonymous hashes from blocks, but I don't know what, if anything, "+["
> > > does.
> > +{} disambiguates an anonymous hash from a block because a block cannot
> > be used as the operand of unary +, while an anonymous hash can.
>
> Originally, I was into anonymous hashes and read that +{} is not ambiguous
> whereas a plain {} can be; I got into the habit of using +{} when I meant
> "anonymous hash" (it was one extra keystroke to prevent a possible bug).
> When I started using anonymous arrays, I automatically put the + in front
> of [] without having consulted the manual going on the assumption that
> there might be an ambiguous case so it would not hurt to put it there.
Where is {} ambiguous?
--
Kevin Reid. | Macintosh.
"I'm me." | Think different.
------------------------------
Date: Mon, 09 Nov 1998 02:39:23 GMT
From: K <customer@shaw.wave.ca>
Subject: Compilation Error?
Message-Id: <36465800.7C9D9BEC@shaw.wave.ca>
I just recently started to dive into the world of Perl and wrote a short
script to take the contents of a user defined text file and throw it's
contents onto a dynamic webpage. But I'm not sure if I'm handling the
imput correctly. The text files have the same name configuration (eg.
1-002, 1-003, etc.) so I thought I could just have a listing of the
filenames to choose from and the script would insert the number infront
of the .txt extension, read the file and insert it on a webpage. For an
experienced Perl programmer this is probably a very simple script, but I
can't get it to work. I tried checking it through telnet but it gives me
a compilation error and I'm not familiar with this at all. If anybody
with experience could give me some advice I'd really appreciate. Here's
my script so far:
#!/usr/local/bin/perl
#
$i=0;
read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});
@pairs = split(/&/,$buffer);
foreach $pair (@pairs){
($name,$value) = split(/=/,$pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$FORM{$name} = $value;
}
if ($FORM{'selection'} ne ""){ $report = "$FORM{'selection'}"; }
open(TEXTFILE, "$report.txt");
@file = <TEXTFILE>;
print "Content-type: text/html\n\n";
print "<html><head><title>Report </title></head>\n";
print "<body link=#0000FF vlink=#0000FF alink=#0000FF
background=\"/bighits/paper.jpg\">\n";
print "<div align=\"center\"><center>\n";
print "<table border=\"0\" cellpadding=\"2\" width=\"98%\">\n";
print "<tr>\n";
print "<td width=\"100%\"><strong><font face=\"MS Sans Serif\">\n";
print @file;
print "</font></strong></td>\n";
print "</tr>\n";
print "</table>\n";
print "</center></div>\n";
print "</body></html>\n";
}
------------------------------
Date: Mon, 9 Nov 1998 00:08:59 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Compilation Error?
Message-Id: <1di788r.akgbje1fj78g0N@bay1-8.quincy.ziplink.net>
K <customer@shaw.wave.ca> wrote:
> [...]
The subject of your post suggests that your script had a compilation
error.
Would you be offended if I were to ask just what that compilation error
was?
(I would guess it has something to do with 6 left curly braces and 7
right curly braces. :-)
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Mon, 09 Nov 1998 10:32:54 +1000
From: Paul Buchanan <buchanpj@hatespam.citec.qld.gov.au>
Subject: Effectively replacing browser's history entries
Message-Id: <36463836.21287C15@hatespam.citec.qld.gov.au>
I'm sure everyone is familiar with the situation whereby if you have a
redirect rule set on a server for a particular directory/page/entire
server and the browser location is changed to the correct/new page and
when you get to that new page, even if you click Back it won't take you
to the previous (old/wrong) location....
...based on this, I'd like to know if you can do the same but without
there having to be a redirection set... so that you could change the
browser location and replace the entry in the browser's history so that
even if you clicked Back you wouldn't be returned to the previous page.
I know how to do this with JavaScript 1.1 [it's
location.replace(newlocation)] but I'd prefer a server-based solution...
I would sincerely appreciate any assistance,
Ta
Paul Buchanan
------------------------------
Date: Mon, 09 Nov 1998 00:48:29 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Effectively replacing browser's history entries
Message-Id: <Pine.GSO.4.02A.9811081647080.14028-100000@user2.teleport.com>
On Mon, 9 Nov 1998, Paul Buchanan wrote:
> Subject: Effectively replacing browser's history entries
> I know how to do this with JavaScript 1.1 [it's
> location.replace(newlocation)] but I'd prefer a server-based
> solution...
It sounds as if you want to get a browser or a server to do something.
Perhaps the docs, FAQs, and newsgroups about browsers, servers, and
related issues would be of help to you. Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 09 Nov 1998 11:34:42 +1300
From: Kelvin Price <kprice@cardinal.co.nz>
Subject: Re: file contains files
Message-Id: <36461C82.C31E599C@cardinal.co.nz>
Chris wrote:
>
> Hello everbody !
>
> A Newbie (that's me) has a been looking for a - I guess simple - answer,
> but couln't find it, perhaps it's not that common.
>
> Problem : I got a large file A, which contains filenames (incl. abs.
> path).
> My perl-script should : parse this file A, every line could be an
> argument for "cat" or "print". (the resulting output will then be
> filtered, but that's not the problem).
>
> I'm looking for a possibility to assign a certain content of a file (for
> instance a line) to a variable which then serve as a filename.
>
> Like :
> open (fileA);
> varL=line(fileA);
> open(varL);
>
> thanks in advance
>
> Chris
open RTFM, "<perldoc";
while (<RTFM>) {
system("cat $_ | users_brain");
};
close RTFM;
8-D
------------------------------
Date: 9 Nov 1998 03:53:45 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: file contains files
Message-Id: <slrn74cpq8.iso.sholden@pgrad.cs.usyd.edu.au>
On Sun, 08 Nov 1998 16:08:50 +0100, Chris <binder@cs.tu-berlin.de> wrote:
>Hello everbody !
>
>A Newbie (that's me) has a been looking for a - I guess simple - answer,
>but couln't find it, perhaps it's not that common.
>
>Problem : I got a large file A, which contains filenames (incl. abs.
>path).
>My perl-script should : parse this file A, every line could be an
>argument for "cat" or "print". (the resulting output will then be
>filtered, but that's not the problem).
>
>I'm looking for a possibility to assign a certain content of a file (for
>instance a line) to a variable which then serve as a filename.
>
>Like :
>open (fileA);
>varL=line(fileA);
>open(varL);
>
>thanks in advance
I don't see a question anywhere...
Why not RTFM and turn your pseudo-code above into perl...
--
Sam
testing? What's that? If it compiles, it is good, if it boots up it is
perfect.
--Linus Torvalds
------------------------------
Date: Sun, 08 Nov 1998 21:10:17 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: HELP w/ Perl & PC Parallel Port
Message-Id: <Pine.GSO.4.02A.9811081309560.14028-100000@user2.teleport.com>
On 8 Nov 1998, Wendy Allison Verschoor wrote:
> Subject: HELP w/ Perl & PC Parallel Port
Have you seen what the FAQ has to say about this? Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 07 Nov 1998 21:18:20 -0500
From: Aravind Subramanian <aravind@genome.wi.mit.edu>
Subject: Re: History of Perl
Message-Id: <3644FF6C.F834535A@genome.wi.mit.edu>
Links abound at
http://language.perl.com/index.html
Jonathan Bartlett wrote:
> Does anyone know a site I can visit that has the history of the Perl
> programming lnaguage?
>
> Jonathan Bartlett
------------------------------
Date: Sun, 08 Nov 1998 20:14:06 GMT
From: Ron Parker <sysop@scbbs.com>
Subject: net::nntp
Message-Id: <3645FB87.BA74BF44@scbbs.com>
Where can I find an example of a script used to fetch
newsgroups/articles? I looked at www.cpan.org, also did a perldoc
net::nntp, but cannot find actual script examples.
Thanks for any suggestions.
-ron
--
Ron Parker
TradePoint LA / Tradewinds / SCBBS
www.intl-trade.com
www.tradepointla.org
www.scbbs.com
------------------------------
Date: Sun, 8 Nov 1998 18:04:42 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: net::nntp
Message-Id: <MPG.10afceff901f268f989707@news.scescape.net>
In article <3645FB87.BA74BF44@scbbs.com>, Ron Parker <sysop@scbbs.com>
pounded in the following:
=> Where can I find an example of a script used to fetch
=> newsgroups/articles? I looked at www.cpan.org, also did a perldoc
=> net::nntp, but cannot find actual script examples.
In addition to Daniel's suggestion, check out:
http://www.stonehenge.com/merlyn/UnixReview/col22.html
=> Thanks for any suggestions.
HTH,
=> -ron
--Matthew
------------------------------
Date: 09 Nov 1998 06:44:50 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Not to start a language war but..
Message-Id: <910593753.584782@thrush.omix.com>
[posted & mailed]
Clemens Hintze <cle@qiao.in-berlin.de> wrote:
: In article <910414036.641270@thrush.omix.com>, Zenin wrote:
: > And to any 5 day old Perl programmer, an 'eval{block}; if ($@){}'
: > statement is equally as reflective.
: >
: > If the "Purer OO" languages could agree on any of this (Python has
: > except: while Java has catch, etc) I might give you more points
: > here. But they don't, so I can't.
: I have a question. Given that there is a tarmodule for Perl which also wants to
: raise exceptions on error, how would you program the following in Perl please?
...And this relates to what you quoted of me, how exactly?
: import tarlib
>snip Python tar example<
: I mean that question serious!
Sure ya did. :-)
: You've said, that Perl does not need exceptions.
Programming at large does not "need" exceptions. Exceptions are
just one of many tools that may or may not be the best to use for a
particular task. Of course any tool can be used for any task, it
just won't be as easy to use. Take the common example from
carpentry, "*Any* tool is a hammer, except a hammer because it's
a crowbar."
There are times exceptions make lots of sense, and there are just
as many times they don't. My rule of thumb (but most certainly not
a hard rule by any chance), is that functions should set $@ (or some
other error global) and return false, while methods should normally
throw exceptions. This is only a very, very basic starting point
however, and many other factors play a part, as it is with anything
in design.
: But I cannot guess, how to do it in Perl without exceptions.
Actually, since the Archive::Tar module throws no exceptions, so
you'd have a hard time doing it *with* exceptions. :-)
use Archive::Tar;
my $tarFile = "$ENV{HOME}/myconfig.tar";
my @files = ("$ENV{HOME}/.bashrc", "$ENV{HOME}/.profile", "$ENV{HOME}/.tcshrc");
my $tp = Archive::Tar->new($tarFile)
or die "Can not open tar file '$tarFile': $Tar::error, stopped";
$tp->add_files(@files)
or die "Can not add files '@files' to tar file: $Tar::error, stopped";
$tp->write($tarFile)
or die "Can not save tar file '$tarFile': $Tar::error, stopped";
print "All files added\n";
: I did not write that to show Python is better than Perl or vice versa.
Probably because all things considered, they are pretty much equal.
: I have used Perl4 for years. Than Perl5 (not very long), now Python.
: But I have only used "die", never Perl5's warn, croak, barf or whatever ;-)
So you should be right at home with Archive::Tar, all you need is
die(). :-)
: Although I will not use Perl very often in future, I nevertheless not want to
: loose the contact with it. So please be so kind to show me thy Perl's way to
: go for such kind of problem.
There you have it. If you don't have the Archive::Tar module (or
want to upgrade a copy you do have), you can download, build, test,
and install it with just the simple command:
perl -MCPAN -e 'install "Archive::Tar"'
Isn't insightful integration great?
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Mon, 9 Nov 1998 14:38:39 +0800
From: "Perl Writer" <perl_writer@hotmail.com>
Subject: Passing reference from C to Perl
Message-Id: <7262jm$8l7$1@imsp009a.netvigator.com>
I want to write a C function which will invoke a Perl subroutine, passing in
a reference of associative array.
The code I wrote is as follows. However, the Perl script cannot get the
value of the field1 in the passed-in data structure. Can anybody tell me
what's wrong with the following code fragment or whether it is possible to
pass reference from C to Perl? Thanks a lot for your help.
argument.c
=========
#include <EXTERN.h>
#include <perl.h>
typedef struct AStruct
{
int field1;
bool field2;
} HashStruct;
static void invoke_perl_script(HashStruct data)
{
HV* hv = newHV();
SV* sv;
dSP;
ENTER;
SAVETMPS;
hv_store(hv, "field1", 128, sv_2mortal(newSViv(in_struct.field1)), 0);
hv_store(hv, "field2", 128, sv_2mortal(newSViv(in_struct.field2)), 0);
sv = sv_2mortal(newRV_inc((SV*) hv));
PUSHMARK(SP);
XPUSHs(sv);
PUTBACK;
perl_call_pv("test", G_DISCARD);
PUTBACK;
FREETMPS;
LEAVE;
perl_destruct(pl);
perl_free(pl);
printf("bye\n");
}
int main(int argc, char* argv[], char **env)
{
HashStruct data;
char *my_argv[] = { "", "argument.pl" };
HV* hv;
data.field1 = 102;
data.field2 = FALSE;
pl = perl_alloc();
perl_construct(pl);
perl_parse(pl, NULL, 2, my_argv, (char**) NULL);
perl_run(pl);
invoke_perl_script(data);
}
argument.pl
=========
#!/bin/perl
sub test
{
local($data) = @_;
print ("data field1 = " . $data->{"field1"} . "\n");
# even print ("data field1 = " . $$data{"field1"} . }\n"); does not
work
}
------------------------------
Date: Mon, 09 Nov 1998 02:15:34 GMT
From: gdeering(NO#!%&SPAM)csu.edu.au (Geoff Deering)
Subject: Re: perl cgi tutorial
Message-Id: <36464fe2.263711076@newsagent>
Probably the best place to start is http://reference.perl.com/
On Fri, 6 Nov 1998 09:47:31 +0200, "John Spyrou"
<infotec@mail.otenet.gr> wrote:
>I have downloaded perl for windows and I am a linux user too. I have found
>some cgi scripts writen in perl but I really dont know the language.
>So I would be pleased if someone could tell me a good
>perl tutorial and if it is about cgi programming too it will be great.
>Can I find tutorials for both sublects somewhere ?
>
>thanx in advance
>George Statis
>
>
------------------------------
Date: Sun, 08 Nov 1998 09:45:07 GMT
From: Rocko <rickmoy@NOSPAM-yahoo.com>
Subject: regexp for IP address / host-domain
Message-Id: <36456661.2CF19C1E@NOSPAM-yahoo.com>
I know I've seen this somewhere but can't remember where. Is there a
regexp that will match an IP address in the form of 1.2.3.4 or similarly
hostname.domain.orgtype ?
------------------------------
Date: 9 Nov 1998 01:32:28 GMT
From: awrobinson@aol.com (Awrobinson)
Subject: Re: shift in a list context
Message-Id: <19981108203228.19458.00001208@ng41.aol.com>
This response really bothered me. Here's what I think was bad about it:
1. Empiricism doesn't always work. The classic example given in "Effective Perl
Programming" is
open( FIN, "foo" ) || die;
while( <FIN> ) {...
If I tried this, it would seem to work. It's only obscure situations that it
would not.
2. Your statement about it being quicker to look something up or try it is not
always true. There have been many times when I tried to look something up, but
didn't know enough to find the info I was looking for. A personal example was
"lookahead" in regular expressions. I got that phrase from a question I posted
on this newsgroup in minutes.
3. Your veiled insult about my posting from America Online. Well let me tell
you why. The CIO of the Fortune 100 company I work for decided to shut down
USENET access within the company several years ago. The reason? He was afraid
that an employee seeing offensive material in some odd newsgroup could sue the
company. I lobbied to get access back to the computer newsgroups and it
happened, but very inconsistently. I get results much quicker by posting from
America Online at home than though my company's access.
4. In the time it took you to come up with your snappy response, you could have
answered my question. I try to make my questions focused, and a yes-no question
is about as focused as I could get. If you don't like my question, don't
respond.
5. The fact that you did respond with insulting answers, I can only conclude
that you wanted to show off your superior intelligence. So, do you think were
you were successful Mr. McAfee?
Andrew Robinson
>From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
>> If I coded something like:
>
>> sub mysub {
>> ( $first, $second ) = shift;
>
>>would I get the first two elements of @_?
>
>Empiricism is dead, it seems...
>
>Try it and see. It'll take all of two minutes--much less time than waiting
>for an answer on Usenet. Alternately, read the "shift" entry in the
>perlfunc manual page. Either way, you'll get a definitive answer.
>
>>Disclaimer: The opinions expressed are mine alone and do not represent
>the
>>views of America Online
>
>...Must...control...gratuitous...AOL...comment...
------------------------------
Date: Sun, 08 Nov 1998 09:41:11 GMT
From: Rocko <rickmoy@NOSPAM-yahoo.com>
Subject: syslog msg format?
Message-Id: <36456576.4A48E0D2@NOSPAM-yahoo.com>
I'm listening on a UDP port 514 for syslog messages and seem to be
getting lots of text. I can discern the message portion, but can't find
the msg priority or facility identifiers - readily.
All the messages are preceeded by <166>%
Any ideas or pointers to syslogd type code?
Thanks
------------------------------
Date: Sun, 08 Nov 1998 20:11:18 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Testing for a number (was: Re: a small question)
Message-Id: <Pine.GSO.4.02A.9811081149120.14028-100000@user2.teleport.com>
On Sat, 7 Nov 1998, Matthew Bafford wrote:
> Out of curiosity, is there anything wrong with something like this:
>
> #!/usr/bin/perl -w
> use strict;
>
> sub isanumber {
> my $isanumber = 1;
>
> {
> local $SIG{__WARN__} = sub { $isanumber = 0; };
>
> 1 if $_[0] + 0;
> }
>
> $isanumber;
> }
Nothing wrong with it in principle. (You should be sure to turn on
warnings, though, since someone may have them disabled for whatever
reason.)
> I'd think it'd be slightly better than using a regex, especially since
> it accepts any of Perl's idea of number.
I like that, too. But I'd probably write it more like this, with some
extra junk so that we won't be bothered by a compile-time warning.
BEGIN {
local $^W; # no warnings at compile-time
BEGIN { $^W = 0 }
sub is_number {
local $^W = 1; # warnings enabled
local $SIG{'__WARN__'} = sub { die }; # and fatal
local $SIG{'__DIE__'}; # and not some other handler
scalar eval { 0+$_[0], 1 };
}
}
That should be what (I think) most people would want, albeit relatively
slow. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 8 Nov 1998 23:35:22 -0500
From: "Pap" <Pap22@erols.com>
Subject: Re: Why doesn't my perl compiler like this expression?
Message-Id: <725rgk$8kr$1@autumn.news.rcn.net>
Newbie response:
Well, if you think about it, perl doesnt need to do any real math in (i) and
(ii), it just sets it to 0 and shuts up about it. but in (iii), it does
need to do math, so that may be why (iii) doesn't work and (i) and (ii) do.
sara starre wrote in message <36465FE2.1203CBDD@hotmail.com>...
>if
> (i) $a=$b=$c=0;
>and
> (ii) $a=$b=$c=1;
>
>are fine, and seem to work correctly, then why does the compiler not
>like:
>
> (iii) $a=1+$b=$c=0;
>
>???
>
>Parsing from r to l, each l-value has a legit r-value. We could argue
>that an LR parser would encounter an undefined r-value in (iii) when it
>parses $a=1+$b, since $b isn't defined yet. However, exactly the same
>argument can be made in (i) and (ii). I'm confused!
>
>HUG,
>S
>
------------------------------
Date: 08 Nov 1998 22:58:28 -700
From: Daniel Grisinger <dgris@rand.dimensional.com>
Subject: Re: Why doesn't my perl compiler like this expression?
Message-Id: <m3zpa1flvf.fsf@rand.dimensional.com>
sara starre <nospam.gear4u@hotmail.com> writes:
> why does the compiler not
> like:
>
> (iii) $a=1+$b=$c=0;
Precedence.
> Parsing from r to l, each l-value has a legit r-value.
But you don't have 3 valid l-values. You have-
$c = 0; # this is fine :-)
1 + $b = $c; # oops!
and it blows up. This will do what you are trying-
$a = 1 + ($b = $c = 0);
dgris
--
Daniel Grisinger dgris@rand.dimensional.com
Supporter of grumpiness where grumpiness is due on clpm.
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 4177
**************************************