[12641] in Perl-Users-Digest
Perl-Users Digest, Issue: 50 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 7 09:17:50 1999
Date: Wed, 7 Jul 1999 06:07:31 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 7 Jul 1999 Volume: 9 Number: 50
Today's topics:
Statistics for comp.lang.perl.misc <gbacon@cs.uah.edu>
stdio back to DOS shell <StefanRieken@SoftHome.net>
Re: stdio back to DOS shell (Andrew Allen)
Re: stdio back to DOS shell (Eric Bohlman)
Syntax-Highlighting-Editor-Thingie <cameron_graham@clear.net.nz>
Re: Syntax-Highlighting-Editor-Thingie (Bart Lateur)
Re: Syntax-Highlighting-Editor-Thingie <swiftkid@bigfoot.com>
Re: system call <walton@frontiernet.net>
Tell me it aint so <seth@home-industires>
Re: Tell me it aint so (M.J.T. Guy)
Re: Tell me it aint so sethr@crocker.com
Re: test for one of a number of values (more than one w <anfi@bigfoot.com>
Re: test for one of a number of values (more than one w <flavell@mail.cern.ch>
Re: test for one of a number of values (more than one w (Bart Lateur)
Re: test for one of a number of values (more than one w (Mark-Jason Dominus)
Re: test for one of a number of values (more than one w <flavell@mail.cern.ch>
Re: test for one of a number of values (more than one w <anfi@bigfoot.com>
Re: test for one of a number of values (more than one w <uri@sysarch.com>
Re: test for one of a number of values (more than one w (Abigail)
Re: text editing question???? <gellyfish@gellyfish.com>
Re: text editing question???? <sjs@yorku.ca>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Jul 1999 15:40:42 GMT
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: Statistics for comp.lang.perl.misc
Message-Id: <7lqjlq$2e8$1@info2.uah.edu>
Following is a summary of articles spanning a 7 day period,
beginning at 28 Jun 1999 15:36:16 GMT and ending at
05 Jul 1999 07:02:04 GMT.
Notes
=====
- A line in the body of a post is considered to be original if it
does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
- All text after the last cut line (/^-- $/) in the body is
considered to be the author's signature.
- The scanner prefers the Reply-To: header over the From: header
in determining the "real" email address and name.
- Original Content Rating (OCR) is the ratio of the original content
volume to the total body volume.
- Find the News-Scan distribution on the CPAN!
<URL:http://www.perl.com/CPAN/modules/by-module/News/>
- Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
- Copyright (c) 1999 Greg Bacon.
Verbatim copying and redistribution is permitted without royalty;
alteration is not permitted. Redistribution and/or use for any
commercial purpose is prohibited.
Excluded Posters
================
perlfaq-suggestions\@(?:.*\.)?perl\.com
Totals
======
Posters: 586
Articles: 1890 (689 with cutlined signatures)
Threads: 516
Volume generated: 3316.3 kb
- headers: 1462.5 kb (29,442 lines)
- bodies: 1705.4 kb (54,366 lines)
- original: 1196.4 kb (41,010 lines)
- signatures: 146.6 kb (2,963 lines)
Original Content Rating: 0.702
Averages
========
Posts per poster: 3.2
median: 1.0 post
mode: 1 post - 342 posters
s: 8.8 posts
Posts per thread: 3.7
median: 3.0 posts
mode: 1 post - 155 threads
s: 4.7 posts
Message size: 1796.8 bytes
- header: 792.4 bytes (15.6 lines)
- body: 924.0 bytes (28.8 lines)
- original: 648.2 bytes (21.7 lines)
- signature: 79.4 bytes (1.6 lines)
Top 10 Posters by Number of Posts
=================================
(kb) (kb) (kb) (kb)
Posts Volume ( hdr/ body/ orig) Address
----- -------------------------- -------
133 323.3 (151.8/113.9/106.2) abigail@delanet.com
76 120.6 ( 57.7/ 49.4/ 26.5) Jonathan Stowe <gellyfish@gellyfish.com>
74 89.6 ( 53.1/ 36.4/ 19.7) "Faisal Nasim" <swiftkid@bigfoot.com>
59 91.2 ( 35.2/ 55.9/ 35.0) tadmc@metronet.com (Tad McClellan)
45 65.6 ( 38.3/ 27.2/ 17.7) bart.lateur@skynet.be (Bart Lateur)
41 164.0 ( 34.2/125.0/117.3) tchrist@mox.perl.com (Tom Christiansen)
38 102.2 ( 33.9/ 55.9/ 27.4) Uri Guttman <uri@sysarch.com>
30 57.6 ( 23.9/ 30.2/ 18.3) David Cassell <cassell@mail.cor.epa.gov>
30 45.0 ( 28.2/ 13.2/ 8.7) Tom Phoenix <rootbeer@redcat.com>
26 42.0 ( 19.8/ 16.3/ 8.1) rjk@linguist.dartmouth.edu (Ronald J Kimball)
These posters accounted for 29.2% of all articles.
Top 10 Posters by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Address
-------------------------- ----- -------
323.3 (151.8/113.9/106.2) 133 abigail@delanet.com
164.0 ( 34.2/125.0/117.3) 41 tchrist@mox.perl.com (Tom Christiansen)
120.6 ( 57.7/ 49.4/ 26.5) 76 Jonathan Stowe <gellyfish@gellyfish.com>
102.2 ( 33.9/ 55.9/ 27.4) 38 Uri Guttman <uri@sysarch.com>
91.2 ( 35.2/ 55.9/ 35.0) 59 tadmc@metronet.com (Tad McClellan)
89.6 ( 53.1/ 36.4/ 19.7) 74 "Faisal Nasim" <swiftkid@bigfoot.com>
65.6 ( 38.3/ 27.2/ 17.7) 45 bart.lateur@skynet.be (Bart Lateur)
57.6 ( 23.9/ 30.2/ 18.3) 30 David Cassell <cassell@mail.cor.epa.gov>
47.9 ( 16.6/ 27.6/ 19.0) 16 morpheus@here.not.there
46.0 ( 14.9/ 31.1/ 13.6) 24 anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
These posters accounted for 33.4% of the total volume.
Top 10 Posters by OCR (minimum of five posts)
==============================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.938 (117.3 /125.0) 41 tchrist@mox.perl.com (Tom Christiansen)
0.933 (106.2 /113.9) 133 abigail@delanet.com
0.922 ( 8.9 / 9.7) 15 fl_aggie@thepentagon.com
0.909 ( 5.2 / 5.7) 5 "Cameron Graham" <cameron_graham@clear.net.nz>
0.881 ( 20.2 / 23.0) 18 Greg Bacon <gbacon@cs.uah.edu>
0.874 ( 6.6 / 7.5) 7 edmundsMUNGED@pacifierMUNGED.com (doug edmunds)
0.865 ( 7.1 / 8.2) 5 Bob Walton <walton@frontiernet.net>
0.814 ( 17.0 / 20.8) 8 snowhare@long-lake.nihongo.org (Benjamin Franz)
0.814 ( 3.6 / 4.4) 8 R . Joseph <streaking_pyro@my-deja.com>
0.770 ( 3.5 / 4.5) 5 Andrew J Perrin <aperrin@mcmahon.qal.berkeley.edu>
Bottom 10 Posters by OCR (minimum of five posts)
=================================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.482 ( 1.7 / 3.5) 6 "Troy Knight" <troyknight@troyknight.eurobell.co.uk>
0.472 ( 6.4 / 13.6) 19 ada@fc.hp.com (Andrew Allen)
0.456 ( 0.8 / 1.7) 6 Craig Ciquera <craig@mathworks.com>
0.440 ( 3.5 / 7.9) 5 Steve Palincsar <palincss@his.com>
0.438 ( 13.6 / 31.1) 24 anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
0.359 ( 1.0 / 2.9) 5 redmondm@yahoo.com ()
0.358 ( 2.6 / 7.3) 5 Robert de Geus <robert@corpus.nl>
0.352 ( 1.7 / 4.9) 5 dave@dave.org.uk (Dave Cross)
0.324 ( 1.2 / 3.6) 5 td90537@hotmail.com
0.180 ( 1.2 / 6.8) 5 Greg Bartels <gbartels@xli.com>
72 posters (12%) had at least five posts.
Top 10 Threads by Number of Posts
=================================
Posts Subject
----- -------
51 2 simple (not to me tho) questions
36 Robot email/poster for this group
33 hiring perl programmers
33 getting script source
24 Top 10 responses to the Robot/email idea
23 make my day fix an array :-)
22 Apples and Oranges
19 Perl or PNP...which is better?
17 regexp riddle
17 Forms Processing - thread started in HTML group
These threads accounted for 14.6% of all articles.
Top 10 Threads by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Subject
-------------------------- ----- -------
140.7 ( 51.7/ 80.3/ 51.4) 51 2 simple (not to me tho) questions
85.3 ( 29.0/ 53.2/ 33.0) 36 Robot email/poster for this group
79.0 ( 1.5/ 77.3/ 77.2) 2 banner_rotate.pl for linux /usr/games/banner
76.4 ( 30.3/ 41.1/ 31.0) 33 hiring perl programmers
53.5 ( 20.4/ 31.5/ 21.7) 24 Top 10 responses to the Robot/email idea
52.2 ( 25.6/ 23.9/ 15.0) 33 getting script source
48.7 ( 20.6/ 24.0/ 13.4) 23 make my day fix an array :-)
36.4 ( 15.3/ 19.9/ 13.3) 22 Apples and Oranges
33.8 ( 6.8/ 26.0/ 22.5) 9 Order of Output
30.9 ( 15.1/ 13.5/ 7.8) 17 Forms Processing - thread started in HTML group
These threads accounted for 19.2% of the total volume.
Top 10 Threads by OCR (minimum of five posts)
==============================================
(kb) (kb)
OCR orig / body Posts Subject
----- -------------- ----- -------
0.929 ( 3.8/ 4.1) 6 Search Engine Problem -- newbie question
0.895 ( 11.5/ 12.8) 10 Date::Manip can't handle Arizona Time zone?
0.866 ( 22.5/ 26.0) 9 Order of Output
0.855 ( 2.9/ 3.4) 6 running perl script
0.841 ( 6.3/ 7.5) 7 how do I open a % based on a $ ?
0.834 ( 9.5/ 11.4) 8 name confusion
0.832 ( 3.2/ 3.9) 7 MKTEMP
0.811 ( 1.2/ 1.5) 5 Is it possible (some how) to "compile" a Perl script to an .exe ?
0.810 ( 6.8/ 8.4) 9 Starting asynchronous process from Perl
0.803 ( 1.2/ 1.5) 5 differentiate btw big-endian machine and small-endian machine
Bottom 10 Threads by OCR (minimum of five posts)
=================================================
(kb) (kb)
OCR orig / body Posts Subject
----- -------------- ----- -------
0.492 ( 2.1 / 4.2) 5 passing Perl hash to javascript
0.475 ( 2.0 / 4.2) 5 Communication between CGI and apache
0.469 ( 2.2 / 4.7) 6 Premature end of script headers:
0.449 ( 2.4 / 5.4) 6 Copying Lines to File
0.448 ( 3.4 / 7.6) 11 random numbers ?
0.442 ( 3.7 / 8.4) 6 text editing question????
0.407 ( 1.4 / 3.5) 9 Linux better than perl?
0.400 ( 1.8 / 4.5) 5 UK Perl job vacancy
0.397 ( 2.9 / 7.3) 8 regExpr question.
0.274 ( 1.9 / 6.8) 6 FAQ 4.28: How do I capitalize all the words on one line?
119 threads (23%) had at least five posts.
Top 10 Targets for Crossposts
=============================
Articles Newsgroup
-------- ---------
25 comp.lang.perl.modules
8 comp.lang.perl.moderated
7 comp.unix.shell
7 comp.infosystems.www.servers.unix
7 comp.lang.perl
4 alt.perl
4 alt.html
4 alt.internet.search-engines
3 comp.unix.questions
3 comp.unix.admin
Top 10 Crossposters
===================
Articles Address
-------- -------
5 ken@halcyon.com
5 "TOOLS Conferences" <tools@tools.com>
4 e-lephant@b-igpond.com (elephant)
4 johnpc@xs4all.net
3 Loki <joeh@adm.com>
3 abigail@delanet.com
3 fl_aggie@thepentagon.com
3 bart.lateur@skynet.be (Bart Lateur)
3 thomasgd@omc.bt.co.uk (Greg Thomas)
3 Bob Shair <bshair@itds.com>
------------------------------
Date: Sat, 03 Jul 1999 19:42:38 +0200
From: Stefan Rieken <StefanRieken@SoftHome.net>
Subject: stdio back to DOS shell
Message-Id: <377E4B8E.15F9E7BD@SoftHome.net>
Hello,
This is maybe merely an MS-DOS question. But please do not just remark
that I am SO WRONG that I post it here, without answering my question.
That would help neither of us, would it?
I would like to be able to redirect my STDIO from HTTP to DOS. So that,
for example, when a user accesses my Perl script via CGI (in whatever
specific way) and sends a message, I would be able to read that message
(a kind of simple ICQ, please don't steal the funny idea :).
I would be able to read the message because I have my home PC as a tiny
server, so that's also the place where the script is executed.
Now what I wondered was: how do you redirect, or anyway assign an I/O
stream to the DOS screen? (I only know the Amiga CON: drive system.)
Any help would be appreciated.
Greets,
Stefan
------------------------------
Date: 3 Jul 1999 19:25:28 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: stdio back to DOS shell
Message-Id: <7llo38$a41$6@fcnews.fc.hp.com>
Stefan Rieken (StefanRieken@SoftHome.net) wrote:
: Hello,
: This is maybe merely an MS-DOS question. But please do not just remark
: that I am SO WRONG that I post it here, without answering my question.
: That would help neither of us, would it?
: I would like to be able to redirect my STDIO from HTTP to DOS. So that,
: for example, when a user accesses my Perl script via CGI (in whatever
: specific way) and sends a message, I would be able to read that message
: (a kind of simple ICQ, please don't steal the funny idea :).
In unix, I would append to a file in the CGI script, and run "tail -f
file" (which continuously checks for additions to a file and displays
them) in one of my windows. Does DOS have any kind of 'tail -f'-like
command? If not, there's one in the faq.
Andrew
------------------------------
Date: 5 Jul 1999 00:35:21 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: stdio back to DOS shell
Message-Id: <7louk9$eto@dfw-ixnews11.ix.netcom.com>
Stefan Rieken (StefanRieken@SoftHome.net) wrote:
: I would like to be able to redirect my STDIO from HTTP to DOS. So that,
: for example, when a user accesses my Perl script via CGI (in whatever
: specific way) and sends a message, I would be able to read that message
: (a kind of simple ICQ, please don't steal the funny idea :).
Take a look at Win32::Console.
------------------------------
Date: Tue, 6 Jul 1999 18:51:14 +1200
From: "Cameron Graham" <cameron_graham@clear.net.nz>
Subject: Syntax-Highlighting-Editor-Thingie
Message-Id: <oFhg3.261$_r1.10922@news.clear.net.nz>
just looking round this newsgroup and i saw a couple of messages about the
above thingamjig......
anyone know where i could get somthing like this?
------------------------------
Date: Tue, 06 Jul 1999 08:51:02 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Syntax-Highlighting-Editor-Thingie
Message-Id: <3783c341.2083909@news.skynet.be>
Cameron Graham wrote:
>just looking round this newsgroup and i saw a couple of messages about the
>above thingamjig......
>anyone know where i could get somthing like this?
Go to <http://reference.perl.com/query.cgi?section=editors> for the
links for "editors". That should list most (but not quite all) of them.
Bart.
------------------------------
Date: Tue, 6 Jul 1999 18:03:18 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Syntax-Highlighting-Editor-Thingie
Message-Id: <7lu27n$ed41@news.cyber.net.pk>
Cameron Graham <cameron_graham@clear.net.nz> wrote in message
news:oFhg3.261$_r1.10922@news.clear.net.nz...
> just looking round this newsgroup and i saw a couple of messages about the
> above thingamjig......
> anyone know where i could get somthing like this?
For Windows, try: www.ultraedit.com
For *nix (under X), try: kwrite (comes with KDE)
------------------------------
Date: Fri, 02 Jul 1999 22:18:23 -0400
From: Bob Walton <walton@frontiernet.net>
To: Gary Yerby <guapo@postnet.com>
Subject: Re: system call
Message-Id: <377D72EF.89280689@frontiernet.net>
Gary Yerby wrote:
> I am looking for the commant to type in to log the user out of their session
> in perl.
> would it be system("exit"); ?? if not what would it be?
Gary, that won't work, since system("exit") runs in a separate process. The
"exit" just exits that process. system("logout") won't work either, since the
process in which logout is run is not the login shell. Neither does
exec("logout"). Generally, it looks like there is no way to automatically
logout of a Unix session via a command given in a shell other than the login
shell.
Generally, most users would resent that anyway -- they logged in, and are
expecting the privilege of logging themselves out. There may well be a way to
do it, though. This is really more of a Unix question than a Perl question --
you might have better luck in a Unix newsgroup -- check their FAQ's, then ask
about how to write a shell script to run in an arbitrary shell that will logout
the user. Then just "system" or "exec" that script from your Perl program.
------------------------------
Date: Sat, 3 Jul 1999 07:11:02 -0400
From: Seth Rothberg <seth@home-industires>
Subject: Tell me it aint so
Message-Id: <931000262.725024928@news.crocker.com>
When I use the -T on option on the first line of my PERL script
#!/usr/bin/perl -wT
and then run a check on it from the command line=20
perl -cwT script.cgi=20
I get the message=20
Too late for -T option in script.cgi line 1.
or something like that.
Does this mean that my script is too far gone to even bother with taint
checking?
Thanks,
Seth
------------------------------
Date: 3 Jul 1999 11:48:02 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Tell me it aint so
Message-Id: <7lkt9i$ghm$1@pegasus.csx.cam.ac.uk>
Seth Rothberg <seth@home-industires> wrote:
>When I use the -T on option on the first line of my PERL script
> #!/usr/bin/perl -wT
>and then run a check on it from the command line=20
> perl -cwT script.cgi=20
>I get the message=20
> Too late for -T option in script.cgi line 1.
>or something like that.
>
>Does this mean that my script is too far gone to even bother with taint
>checking?
Well, it's gone too far. Whether it's too far gone, I dunno. :-)
Whenever you get a message from Perl that you don't fully understand,
your first step should be to check the entry in perldiag. In this case
Too late for "-T" option
(X) The #! line (or local equivalent) in a Perl script
contains the -T option, but Perl was not invoked with -T
in its command line. This is an error because, by the
time Perl discovers a -T in a script, it's too late to
properly taint everything from the environment. So Perl
gives up.
If the Perl script is being executed as a command using
the #! mechanism (or its local equivalent), this error
can usually be fixed by editing the #! line so that the
-T option is a part of Perl's first argument: e.g.
change perl -n -T to perl -T -n.
If the Perl script is being executed as perl scriptname,
then the -T option must appear on the command line: perl
-T scriptname.
Mike Guy
------------------------------
Date: Sat, 03 Jul 1999 13:39:17 GMT
From: sethr@crocker.com
Subject: Re: Tell me it aint so
Message-Id: <7ll3q5$6n8$1@nnrp1.deja.com>
Ah, perldiags. Thanks for the tip and the answer.
Seth
In article <7lkt9i$ghm$1@pegasus.csx.cam.ac.uk>,
mjtg@cus.cam.ac.uk (M.J.T. Guy) wrote:
> Seth Rothberg <seth@home-industires> wrote:
> >When I use the -T on option on the first line of my PERL script
> > #!/usr/bin/perl -wT
> >and then run a check on it from the command line=20
> > perl -cwT script.cgi=20
> >I get the message=20
> > Too late for -T option in script.cgi line 1.
> >or something like that.
> >
> >Does this mean that my script is too far gone to even bother with
taint
> >checking?
>
> Well, it's gone too far. Whether it's too far gone, I dunno. :-)
>
> Whenever you get a message from Perl that you don't fully understand,
> your first step should be to check the entry in perldiag. In this
case
>
> Too late for "-T" option
> (X) The #! line (or local equivalent) in a Perl script
> contains the -T option, but Perl was not invoked with -T
> in its command line. This is an error because, by the
> time Perl discovers a -T in a script, it's too late to
> properly taint everything from the environment. So Perl
> gives up.
>
> If the Perl script is being executed as a command using
> the #! mechanism (or its local equivalent), this error
> can usually be fixed by editing the #! line so that the
> -T option is a part of Perl's first argument: e.g.
> change perl -n -T to perl -T -n.
>
> If the Perl script is being executed as perl scriptname,
> then the -T option must appear on the command line: perl
> -T scriptname.
>
> Mike Guy
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Sat, 03 Jul 1999 18:03:39 +0200
From: Andrzej Filip <anfi@bigfoot.com>
Subject: Re: test for one of a number of values (more than one way to do it)
Message-Id: <377E345A.F3D16119@bigfoot.com>
"Alan J. Flavell" wrote:
> In some code I inherited, it's necessary to execute some statements if a
> particular data item has a small-ish number of particular values, and
> bypass them for all other valuse.
>
> The original code spells it out tediously thus:
>
> if ( ($foo{$bar} == 18)
> || ($foo{$bar} == 37)
> || ($foo{$bar} == 42) ) {
> ...statements...
> }
>
> and now I'm at the point of wanting to add some more values to this
> list.
>
> There has to be a more subtle way. Does the team have suggestions?
> (I tried the FAQs but didn't spot anything that seemed a close enough
> match. Apologies if I'm being dim.)
>
> Should I populate an array with the list of values, and test if
> $foo{$bar} is in the list? Seems awkward, Populate a hash, maybe?
>
> It seems one can't write something like
>
> if (defined (18=>1,37=>1,42=>1){$foo{$bar}}) { ... }
Instead try:
my @VALUE=qw( 18 37 48 );
my %VALUE;
# create hash witch keys from @VALUE and every value set to 1
for (@VALUE) { $VALUE{$_}=1;}
if( $VALUE{$foo{bar}} ) {
...statements...
}
> [...]
--
Andrzej (Andrew) A. Filip fax: +1(801)327-6278
mailto:anfi@bigfoot.com http://bigfoot.com/~anfi
Postings: http://deja.com/profile.xp?author=Andrzej%20Filip
------------------------------
Date: Sat, 3 Jul 1999 18:25:41 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: test for one of a number of values (more than one way to do it)
Message-Id: <Pine.HPP.3.95a.990703181714.2458F-100000@hpplus03.cern.ch>
On Sat, 3 Jul 1999, Andrzej Filip wrote:
> > (I tried the FAQs but didn't spot anything that seemed a close enough
> > match. Apologies if I'm being dim.)
OK, I _was_ being dim...
> my @VALUE=qw( 18 37 48 );
> my %VALUE;
> # create hash witch keys from @VALUE and every value set to 1
> for (@VALUE) { $VALUE{$_}=1;}
>
> if( $VALUE{$foo{bar}} ) {
> ...statements...
> }
Indeed. An email has pointed me at the FAQ "How can I tell whether an
array contains a certain element?" which I had missed. Must look harder
next time. Sorry for disturbing you all.
It would be fun to be able to write something like
if (defined (18=>1,37=>1,42=>1){$foo{$bar}}) { ... }
wouldn't it? Oh well.
all the best
------------------------------
Date: Sat, 03 Jul 1999 16:56:30 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: test for one of a number of values (more than one way to do it)
Message-Id: <37814072.2677209@news.skynet.be>
Alan J. Flavell wrote:
>It would be fun to be able to write something like
>
> if (defined (18=>1,37=>1,42=>1){$foo{$bar}}) { ... }
>
>wouldn't it? Oh well.
You can. Use an anonymous hash, and dereference.
if(defined {18 => 1, 37 => 1, 42 => }->{$foo{$bar}}) { ... }
Bart.
------------------------------
Date: Sat, 03 Jul 1999 17:08:56 GMT
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: test for one of a number of values (more than one way to do it)
Message-Id: <7llg27$ee2$1@monet.op.net>
In article <Pine.HPP.3.95a.990703181714.2458F-100000@hpplus03.cern.ch>,
Alan J. Flavell <flavell@mail.cern.ch> wrote:
>It would be fun to be able to write something like
>
> if (defined (18=>1,37=>1,42=>1){$foo{$bar}}) { ... }
>
>wouldn't it? Oh well.
if (defined {18=>1,37=>1,42=>1}->{$foo{$bar}}) { ... }
will work.
The `defined' test is superfluous:
if ({18=>1,37=>1,42=>1}->{$foo{$bar}}) { ... }
------------------------------
Date: Sat, 3 Jul 1999 19:27:26 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: test for one of a number of values (more than one way to do it)
Message-Id: <Pine.HPP.3.95a.990703191343.105A-100000@hpplus03.cern.ch>
On Sat, 3 Jul 1999, Mark-Jason Dominus, and two others (one by email),
wrote:
> if (defined {18=>1,37=>1,42=>1}->{$foo{$bar}}) { ... }
Aha! Thanks.
> will work.
>
> The `defined' test is superfluous:
>
> if ({18=>1,37=>1,42=>1}->{$foo{$bar}}) { ... }
Ah, thanks.
all the best - thanks to all for your patience.
------------------------------
Date: Sat, 03 Jul 1999 19:48:27 +0200
From: Andrzej Filip <anfi@bigfoot.com>
Subject: Re: test for one of a number of values (more than one way to do it)
Message-Id: <377E4CEB.7E0F5C6A@bigfoot.com>
"Alan J. Flavell" wrote:
> On Sat, 3 Jul 1999, Andrzej Filip wrote:
>
> > > (I tried the FAQs but didn't spot anything that seemed a close enough
> > > match. Apologies if I'm being dim.)
>
> OK, I _was_ being dim...
>
> > my @VALUE=qw( 18 37 48 );
> > my %VALUE;
> > # create hash witch keys from @VALUE and every value set to 1
> > for (@VALUE) { $VALUE{$_}=1;}
> >
> > if( $VALUE{$foo{bar}} ) {
> > ...statements...
> > }
>
> Indeed. An email has pointed me at the FAQ "How can I tell whether an
> array contains a certain element?" which I had missed. Must look harder
> next time. Sorry for disturbing you all.
>
> It would be fun to be able to write something like
>
> if (defined (18=>1,37=>1,42=>1){$foo{$bar}}) { ... }
>
> wouldn't it? Oh well.
I hope that the example below is close to what
you want :-)
# memberfunc returns anonymous function
# which returns 1 when when its called with
# member of array given to memberfunc call
sub memberfunc {
my %hash;
local $_;
for (@_) { $hash{$_}=1 };
sub { exists $hash{$_[0]} ? 1 : 0 }
}
my $FValues=memberfunc(18,37,42);
if( &$FValues($foo{$bar})) {
...statements...
}
--
Andrzej (Andrew) A. Filip fax: +1(801)327-6278
mailto:anfi@bigfoot.com http://bigfoot.com/~anfi
Postings: http://deja.com/profile.xp?author=Andrzej%20Filip
------------------------------
Date: 03 Jul 1999 13:57:27 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: test for one of a number of values (more than one way to do it)
Message-Id: <x7r9mpzke0.fsf@home.sysarch.com>
>>>>> "MD" == Mark-Jason Dominus <mjd@op.net> writes:
MD> if ({18=>1,37=>1,42=>1}->{$foo{$bar}}) { ... }
i wonder if that trick is worth the effort? if it is called repeatedly
is should be slower than a prebuilt hash. it is harder to expand beyond
a short list of values before the formatting will boggle your eyes. i
think it is a neat perl trick but not one i would ever use. but who knows,
i never thought i would use the -P option and i did.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: 3 Jul 1999 16:23:19 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: test for one of a number of values (more than one way to do it)
Message-Id: <slrn7nsvpg.31h.abigail@alexandra.delanet.com>
Alan J. Flavell (flavell@mail.cern.ch) wrote on MMCXXXII September
MCMXCIII in <URL:news:Pine.HPP.3.95a.990703165337.2458B-100000@hpplus03.cern.ch>:
$$
$$ In some code I inherited, it's necessary to execute some statements if a
$$ particular data item has a small-ish number of particular values, and
$$ bypass them for all other valuse.
$$
$$ The original code spells it out tediously thus:
$$
$$ if ( ($foo{$bar} == 18)
$$ || ($foo{$bar} == 37)
$$ || ($foo{$bar} == 42) ) {
$$ ...statements...
$$ }
$$
$$ and now I'm at the point of wanting to add some more values to this
$$ list.
$$
$$ It seems one can't write something like
$$
$$ if (defined (18=>1,37=>1,42=>1){$foo{$bar}}) { ... }
You can write:
if ({18 => 1, 37 => 1, 42 =>} -> {$foo {$bar}}) { ... }
But that means building the hash each time you encounter the if.
But you can do:
{my %hash;
BEGIN {%hash = map {$_ => undef} 18, 37, 42}
if (exists $hash {$foo {$bar}}) { ... }
}
which builds the hash only once.
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 4 Jul 1999 20:08:45 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: text editing question????
Message-Id: <7lof0d$47j$1@gellyfish.btinternet.com>
On Fri, 02 Jul 1999 19:32:55 -0500 Michael Carman wrote:
> Isn't assigning to $_ deprecated?
I dont think so - I will often assign to it if, for instance, I am doing
a whole bunch of matches against the same variable or other times when
using the default argument with some function or operator is neater.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Mon, 5 Jul 1999 00:27:46 -0400
From: Steven Smolinski <sjs@yorku.ca>
To: Ray McCormack <ray_mccormack@vcd.hp.com>
Subject: Re: text editing question????
Message-Id: <931149047.1855276831@newshub.ccs.yorku.ca>
Ray,
You didn't escape any of the double-quotes in your string assignment to $_.
Perl is probably parsing it thusly:
$_="<sidebar width=138 align=left><table cellpadding=0 cellspacing=0 border=0>
<tr><TD colspan=1 ALIGN=CENTER valign=top bgcolor=#000000><br><a href="
.. and then continuing with the rest as though they were actual perl
statements.
Steve
On Thu, 01 Jul 1999, Ray McCormack wrote:
>I have the following simple perl script. The intent was to run this on
>a bunch of web pages so that the text inside placed into the $_ variable
>would be inserted into the file right where the first <br> appears.
>
>Perl does not like the line formating I have ... Is there something
>special I am supposed to do to make this work?
>
>#!usr/bin/perl -w
>
>$^I = '.old';
>
>$iterate=0;
>
>while (<>) {
> if (m/<BR>/s) {
> if ($iterate) {
> $_="<sidebar width=138 align=left>
><table cellpadding=0 cellspacing=0 border=0>
><tr><TD colspan=1 ALIGN=CENTER valign=top bgcolor=#000000><br><a
>href="http://www.hp.com/go/webtvprint"><img HSPACE=0 VSPACE=0 border=0
>src="../pix2/hplogob.gif"></a></td>
><td bgcolor="#000000" width=10><font
>size="-2"> </font></td></tr>
><tr colspan=1><TD ALIGN=CENTER bgcolor=#000000>
><img src=../pix/15h15w.gif><br>
><a href="howdoi.html"><img border=0 src=../pix/how_ani.gif><br><img
>vspace=7 border=0 src=../pix/chowdoi.gif></a><br><img
>src=../pix/15h15w.gif><br>
><a href="problems.html"><img border=0 src=../pix/prob_ani.gif><br><img
>vspace=7 border=0 src=../pix/cproblem.gif></a>
><BR clear="all"><a
>href="http://proact.hp.com:5050/escforum/internet.html">
><img border=0 src="../pix/cupani.gif"><BR><img border=0
>src="../pix/saucer.gif"><br><img border=0 src=../pix/qa.gif></a>
><br> <br>
></td><TD bgcolor=#000000> </td>
></TR></TABLE>
></sidebar><ul>
><br>";
> $iterate++;
> }
> }
> print;
>}
>--
>*******************************************************************
>* Ray McCormack * R&D Software Design Engineer *
>*******************************************************************
>* Hewlett Packard * email: ray_mccormack@vcd.hp.com *
>* Vancouver Division * voice: 360-212-6335 *
>* 1115 SE 164th Avenue * fax: 360-212-3960 *
>* Vancouver, WA 98683 * *
>*******************************************************************
>* Sail Smart, Sail Hard, then think about Sailing Fast !!!! *
>*******************************************************************
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
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 V9 Issue 50
************************************