[18261] in Perl-Users-Digest
Perl-Users Digest, Issue: 429 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 6 18:05:50 2001
Date: Tue, 6 Mar 2001 15:05:19 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <983919918-v10-i429@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 6 Mar 2001 Volume: 10 Number: 429
Today's topics:
Re: Feeding value pairs to ASP scripts? horribly@bogus.com
How to set cookies? <sheaney@ntscdallas.com>
Re: How to set cookies? <parrot0123@yahoo.ca>
Re: https redirect in perl? (reader of news)
I dont like when people use wildcard in my form. <kalle@tvettsvamp.a.se>
Re: I dont like when people use wildcard in my form. (Greg Bacon)
Re: I dont like when people use wildcard in my form. <groffg@gmgdesign.com>
Re: Is Perl right for me? (Gwyn Judd)
Re: md5 differences <bmb@ginger.libs.uga.edu>
Oh my god, of course it's always going to be true <centreman_19@yahoo.com>
Perl for System V <groffg@gmgdesign.com>
Re: Perl fortune database - where? (was: Dynamic naming (Richard J. Rauenzahn)
Re: Perl Internals <dan@tuatha.sidhe.org>
Re: Perl Newbie ??? <jrcooke@hardynet.com>
Re: Perl Newbie ??? <groffg@gmgdesign.com>
Re: Perl Newbie ??? <peter.sundstrom-eds@eds.com>
Re: Perl Problem <bart.lateur@skynet.be>
Re: perl-ize and optimize <iltzu@sci.invalid>
Re: pi day (Gwyn Judd)
Re: pi day (John McNamara)
Re: RFC: FAQ3 update -- Using less memory <mjcarman@home.com>
Re: RFC: FAQ3 update -- Using less memory (Ilya Zakharevich)
Re: RFC: FAQ3 update -- Using less memory (Malcolm Dew-Jones)
Re: RFC: FAQ3 update -- Using less memory <dan@tuatha.sidhe.org>
Re: Submitting Forms from Code <iltzu@sci.invalid>
Re: What's wrong with (remedial)... <maheshasolkar@yahoo.com>
Re: What's wrong with (remedial)... <centreman_19@yahoo.com>
Re: What's wrong with (remedial)... <maheshasolkar@yahoo.com>
Re: What's wrong with (remedial)... <ren@tivoli.com>
Re: What's wrong with (remedial)... (Tad McClellan)
Re: What's wrong with (remedial)... <juex@deja.com>
Re: What's wrong with (remedial)... <administrator@playauction.com>
Re: What's wrong with (remedial)... (Richard J. Rauenzahn)
Re: What's wrong with (remedial)... <juex@deja.com>
Whats This ? (=?ISO-8859-1?Q?BigB=90=90=99?=)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 06 Mar 2001 23:01:31 GMT
From: horribly@bogus.com
Subject: Re: Feeding value pairs to ASP scripts?
Message-Id: <3aa56bbc.341916580@news.berkeley.edu>
On Tue, 06 Mar 2001 00:39:41 GMT, sjs@linux.ca (Steven Smolinski)
wrote:
>[Note more evidence for the spamtrapped email bogosity indicator.]
>horribly@bogus.com <horribly@bogus.com> wrote:
>> Is there a different "trick" for
>> feeding value pairs to asp scripts?
>
>What did they say on the ASP newsgroup?
They said 'Ciao bella'. The only asp specific groups I can find are in
Italian and Czech. I thought others with LWP experience might have
faced the same issue.
Hor
------------------------------
Date: Tue, 6 Mar 2001 13:33:48 -0600
From: "Scott Heaney" <sheaney@ntscdallas.com>
Subject: How to set cookies?
Message-Id: <C9DF6105C11AC6AA.AB18A13B0A83AD7C.FDA956F366A5868F@lp.airnews.net>
Hey all ->
I'm having trouble trying to figure out how to set, retrieve, and use
cookies using the CGI mod. Any help is appreciated!
Thanks,
Scott
------------------------------
Date: Tue, 06 Mar 2001 22:05:12 GMT
From: "Parrot" <parrot0123@yahoo.ca>
Subject: Re: How to set cookies?
Message-Id: <sadp6.319880$Pm2.4755374@news20.bellglobal.com>
Scott Heaney <sheaney@ntscdallas.com> wrote in message
news:C9DF6105C11AC6AA.AB18A13B0A83AD7C.FDA956F366A5868F@lp.airnews.net...
> Hey all ->
>
> I'm having trouble trying to figure out how to set, retrieve, and use
> cookies using the CGI mod. Any help is appreciated!
I figured out how to use cookies by studying this script at
http://www.bewley.net/perl/cookie-test.html
It's a very simple script, but it gets the job done. It shouldn't be
too hard for you to figure out how to get it to work with your
programs.
I had some trouble at first, but I figured out what the problem was. The
thing is that you've got to remember to set your cookies before implementing
your text/html header ( the line that looks like this: print "Content-type:
text/html\n\n"; )
It's pretty simple when you figure it out, all you're doing to create a
cookie is printing the command for the browser to set the cookie for you.
The reason you have to print it before the text/html header is that if you
print it afterwards, the browser will interpret it as page output rather
than as a command.
That link I gave you is a pretty simple example for getting started, but it
works very well. There are some cookie libraries out there that are more
complex and allow you more options and such, if you want to take a look here
are a couple of links:
http://www.worldwidemart.com/scripts/cookielib.shtml
http://www.egr.uri.edu/~kovacsp/cookie-lib/
Hope this helps.
------------------------------
Date: 6 Mar 2001 17:34:08 -0500
From: newsreader@mediaone.net (reader of news)
Subject: Re: https redirect in perl?
Message-Id: <3aa565e0$1@oit.umass.edu>
Such sites like to check whether
the agent is javascript capable..
Try sending agent string to present
yourself as knowlegeable about javascript
I would try Mozilla/4.0
On Sun, 4 Mar 2001 17:33:03 +0200,
Howard Morgenstern <howard_morgenstern@hp.com> wrote:
>hey there,
>
>I am trying to do a GET from a https server, which has some kind of security
>mechanism that no matter what URL you give it (even the redirected page) ,
>it sends you a page with a has javascript function that is basically a
>redirect to the login page. The only way to get to the login page is through
>the javascript redirect.
>
>Is there a way to write a perl client script, using whatever modules
>(currently I am using lwp with Crypt-SSLeay, I also have Net::SSLeay) to
>read the reply of the page and get redirected?
>
>thanks
>-howard
>
>
------------------------------
Date: Tue, 06 Mar 2001 21:40:22 GMT
From: "Kalle Anka" <kalle@tvettsvamp.a.se>
Subject: I dont like when people use wildcard in my form.
Message-Id: <aPcp6.22159$AH6.3113454@newsc.telia.net>
Can I prevent it in the script?
------------------------------
Date: Tue, 06 Mar 2001 21:57:02 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: I dont like when people use wildcard in my form.
Message-Id: <taan9eneidcf6c@corp.supernews.com>
In article <aPcp6.22159$AH6.3113454@newsc.telia.net>,
Kalle Anka <kalle@tvettsvamp.a.se> wrote:
: Can I prevent it in the script?
Ignore them:
$form{field} =~ tr/*?//d;
Greg
--
As a general rule, don't solve puzzles that open portals to Hell.
-- Ralph Mason
------------------------------
Date: Tue, 6 Mar 2001 16:58:19 -0500
From: "Garrett Groff" <groffg@gmgdesign.com>
Subject: Re: I dont like when people use wildcard in my form.
Message-Id: <983mgi$2ko$1@zrtph05m.us.nortel.com>
very general question, but you could perhaps use the substitute command
(s/.../...) to replace and '*' with a space.
gmg
"Kalle Anka" <kalle@tvettsvamp.a.se> wrote in message
news:aPcp6.22159$AH6.3113454@newsc.telia.net...
> Can I prevent it in the script?
>
>
------------------------------
Date: Tue, 06 Mar 2001 21:31:52 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Is Perl right for me?
Message-Id: <slrn9aalq7.4rb.tjla@thislove.dyndns.org>
I was shocked! How could Martien Verbruggen <mgjv@tradingpost.com.au>
say such a terrible thing:
>On Tue, 06 Mar 2001 10:16:15 GMT,
> Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
>> I was shocked! How could Martien Verbruggen <mgjv@tradingpost.com.au>
>> say such a terrible thing:
>>>On Tue, 06 Mar 2001 06:15:06 GMT,
>>> Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
>>>> |
>>>> cat /dev/random | sed -e $SOME_SCRIPT > somefile.html
>>>>
>>>> I'm still working on it though
>>>
>>>So... What did you use to write $SOME_SCRIPT? Or is this a recursive
>>>solution?
>>
>> Well, like, *duh*
>>
>> SOME_SCRIPT=`cat /dev/random | sed -e $SOME_OTHER_SCRIPT`
>
>I see...
>
>So... What did you use to write $SOME_OTHER_SCRIPT? Or is this a recursive
>solution?
well of course:
SOME_OTHER_SCRIPT=`head -c 1024 /dev/random`
Like I said, I'm still working on it
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Portability should be the default.
-- Larry Wall in <199711072201.OAA01123@wall.org>
------------------------------
Date: Tue, 6 Mar 2001 15:35:13 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: md5 differences
Message-Id: <Pine.A41.4.21.0103061534390.11388-100000@ginger.libs.uga.edu>
On Tue, 6 Mar 2001, Ted Fiedler wrote:
> On Tue, 6 Mar 2001, Gwyn Judd wrote:
>
> >
> > Insert the line 'undef $/' at the start. You're welcome :)
> >
>
> why am I doing this?
>
> and thanks
To enable "slurp" mode. See perldoc perlvar
Brad
------------------------------
Date: Tue, 6 Mar 2001 11:35:31 -0800
From: "Brandon Thornburg" <centreman_19@yahoo.com>
Subject: Oh my god, of course it's always going to be true
Message-Id: <983ebf$cqi$1@fremont.ohsu.edu>
The light has dawned. Sorry to bore you all with my rookie mistake. Mahesh,
I see now what you mean about && vs. ||. thanks.
------------------------------
Date: Tue, 6 Mar 2001 17:01:14 -0500
From: "Garrett Groff" <groffg@gmgdesign.com>
Subject: Perl for System V
Message-Id: <983mm2$2s5$1@zrtph05m.us.nortel.com>
I need to install Perl on System V. I'd like to use the source, but I
downloaded one compressed source file, containing dozens upon dozens of
files. Is this really going to compile??? How should I compile it? g++ *.c
I'm dubious that that is going to work w/o time-consuming revisions to the
source. Can anyone HELP?!
regards,
Garrett
------------------------------
Date: 6 Mar 2001 21:56:36 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: Perl fortune database - where? (was: Dynamic naming of arrays or hashes)
Message-Id: <983915795.321148@hpvablab.cup.hp.com>
nobull@mail.com writes:
>
>OK, who's maintaining a Perl "fortune" database? That's gotta be
>worthy:
>
>[Elimitiating symrefs so you can "use strict"]... is a little like
>saying you have decided to stop setting your furniture on fire,
>because you want to be able to turn your smoke alarms back on.
> -- Mark Jason Dominus in c.l.p.misc
And...
I don't know what your original problem is,
but I suggest to use a hash.
-- Rafael Garcia-Suarez in c.l.p.misc
http://groups.google.com/groups?hl=en&lr=&group=comp.lang.perl.misc&safe=off&rnum=1&seld=940367237&ic=1
(is there a shorter way to refer to an article on dejagoogle now?)
Rich
--
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant | I speak for me, | 19055 Pruneridge Ave.
Development Alliances Lab| *not* HP | MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014
------------------------------
Date: Tue, 06 Mar 2001 19:22:28 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Perl Internals
Message-Id: <UNap6.12403$Ok4.1734706@news1.rdc1.ct.home.com>
Chris Stith <mischief@velma.motion.net> wrote:
> Jonathan Stowe <gellyfish@gellyfish.com> wrote:
>> On Sat, 3 Mar 2001 16:17:45 -0500 Eduard Grinvald wrote:
>>> Hello All!!
>>> Is there any place where i can determine how perl internally represents data
>>> types and objects. Mostly, i need to know the level of number precision and
>>> how many bytes do references, ints, hashes, etc take up.
>>>
>> This kind of stuff is not documented, you will have to consult the
>> Perl source code.
> Since Perl is implemented in C, and C's primitive data types are allowed to be
> different sizes as the platform allows, it would be good not only to know how
> Perl maps its data types to C types, but also to know how those types are
> respresented on the platform in question.
This is mildly important. Knowing the structure of perl's variables is
more so, and knowing how perl allocates and extends the structures for
arrays and hashes can make the most difference.
> For all I know, every type in Perl maps to a certain defined type in C which
> is defined conditionally based on the platform. Somehow, though, I doubt this.
That would be a good thing, since it's not true. :)
The underlying size of an int does affect the size of perl's data structures,
but not because of the storage allocated to the actual integer value.
The other pieces of the variable data structures will end up taking
most of the space.
dan
------------------------------
Date: Tue, 6 Mar 2001 14:13:14 -0500
From: "Jason Cooke" <jrcooke@hardynet.com>
Subject: Re: Perl Newbie ???
Message-Id: <983cpe$56am$1@news3.infoave.net>
i have installed it in c:\>perl\perl5\ i have created a simple print
program and saved it as test.pl i put that into the bin folder under
perl5 i then went to my prompt and typed c:\>perl\perl5\bin\test.pl
nothing..................
i went in to my install.log and it says it was properly installed but i'm
kind of lost, i have been developing for the web for over 5 years now but
mainly on the graphics side, i am trying to pick up perl to build simple
programs for interactivity between the website and a DB. anyway thanks
for all your assstance....
jason
"Jon Bell" <jtbell@presby.edu> wrote in message
news:G9sDFK.J8w@presby.edu...
> In article <9835he$51dq$1@news3.infoave.net>,
> Jason Cooke <jrcooke@hardynet.com> wrote:
> >how in the world do i get perl installed on windows 2000 any ideas
>
> What problems are you having, specifically?
>
> --
> Jon Bell <jtbell@presby.edu> Presbyterian College
> Dept. of Physics and Computer Science Clinton, South Carolina USA
------------------------------
Date: Tue, 6 Mar 2001 16:50:27 -0500
From: "Garrett Groff" <groffg@gmgdesign.com>
Subject: Re: Perl Newbie ???
Message-Id: <983m1r$2bv$1@zrtph05m.us.nortel.com>
On Unix systems, the syntax is: perl test.pl
Same on Win32?
"Jason Cooke" <jrcooke@hardynet.com> wrote in message
news:983cpe$56am$1@news3.infoave.net...
> i have installed it in c:\>perl\perl5\ i have created a simple
print
> program and saved it as test.pl i put that into the bin folder under
> perl5 i then went to my prompt and typed c:\>perl\perl5\bin\test.pl
> nothing..................
>
> i went in to my install.log and it says it was properly installed but i'm
> kind of lost, i have been developing for the web for over 5 years now but
> mainly on the graphics side, i am trying to pick up perl to build simple
> programs for interactivity between the website and a DB. anyway
thanks
> for all your assstance....
> jason
>
>
> "Jon Bell" <jtbell@presby.edu> wrote in message
> news:G9sDFK.J8w@presby.edu...
> > In article <9835he$51dq$1@news3.infoave.net>,
> > Jason Cooke <jrcooke@hardynet.com> wrote:
> > >how in the world do i get perl installed on windows 2000 any ideas
> >
> > What problems are you having, specifically?
> >
> > --
> > Jon Bell <jtbell@presby.edu> Presbyterian College
> > Dept. of Physics and Computer Science Clinton, South Carolina USA
>
>
------------------------------
Date: Wed, 7 Mar 2001 09:27:31 +1300
From: "Peter Sundstrom" <peter.sundstrom-eds@eds.com>
Subject: Re: Perl Newbie ???
Message-Id: <983h80$8t2$1@hermes.nz.eds.com>
"Jason Cooke" <jrcooke@hardynet.com> wrote in message
news:983cpe$56am$1@news3.infoave.net...
> "Jon Bell" <jtbell@presby.edu> wrote in message
> news:G9sDFK.J8w@presby.edu...
> > In article <9835he$51dq$1@news3.infoave.net>,
> > Jason Cooke <jrcooke@hardynet.com> wrote:
> > >how in the world do i get perl installed on windows 2000 any ideas
> >
> > What problems are you having, specifically?
> i have installed it in c:\>perl\perl5\ i have created a simple
print
> program and saved it as test.pl i put that into the bin folder under
> perl5 i then went to my prompt and typed c:\>perl\perl5\bin\test.pl
> nothing..................
>
> i went in to my install.log and it says it was properly installed but i'm
> kind of lost, i have been developing for the web for over 5 years now but
> mainly on the graphics side, i am trying to pick up perl to build simple
> programs for interactivity between the website and a DB. anyway
thanks
> for all your assstance....
> jason
Here's a *very* useful tip.
Start->Programs->ActiveState ActivePerl->Documentation
------------------------------
Date: Tue, 06 Mar 2001 19:26:05 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl Problem
Message-Id: <v1eaatsd68ij3u40h1kchlb0tk28b245fn@4ax.com>
Sean Chambers wrote:
>I am writing a script that has multiple included files. I seem to have a
>problem with running sub routines without them being called in some of the
>required files. Someone told me this is due to the fact that I did not use
>strict. Any suggestions?
That is absolute rubbish. Using "use strict" you might have noticed it
sooner, but I doubt it.
use strict;
print STDERR "here we go!\n";
foo();
-->
here we go!
Undefined subroutine &main::foo called at TEST.PL line 4.
Nope.
>If i should use strict does anyone have a good
>tutorial on it? Thank you ahead of time.
If you "use strict", you must declare your variables. You can do that
with "my" for lexical variables with limited scope (widest = file), or
with "use vars" or "our" (since 5.6.0) for global, file transcendent
variables. See "perldoc strict", "perldoc vars", "perldoc -f my",
"perldoc -f my" and "perldoc perlsub" for some starting docs.
--
Bart.
------------------------------
Date: 6 Mar 2001 20:35:59 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: perl-ize and optimize
Message-Id: <983910152.514@itz.pp.sci.fi>
In article <9ayo6.24724$W05.5498696@news1.rdc1.mi.home.com>, Dave Brondsema wrote:
>Below is a sub that takes a string and "rotates" it a random amount only
>allowing the break to be at spaces.
>
>This is an example sentence. => an example sentence. This is
>
>My question is how can I optimize this and make it more perlish?
s/(.{${\int rand length}}[^ ]*) (.*)/$2 $1/s;
This one operates on $_ -- feel free to wrap it in a subroutine if you
prefer it that way. It should even yield the exact same statistical
distribution as your original, though I haven't tested that.
BTW, remember to localize $_ if you assign to it in a subroutine.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
'"Intuitive" in this situation can generally be translated as "Try the 100
most likely commands. None of them will work, but you'll kick yourself
when you find out what you should have typed."' -- Charles Miller in SDM
Please ignore Godzilla / Kira -- do not feed the troll.
------------------------------
Date: Tue, 06 Mar 2001 21:39:52 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: pi day
Message-Id: <slrn9aam98.4rb.tjla@thislove.dyndns.org>
I was shocked! How could Joe Schaefer <joe+usenet@sunstarsys.com>
say such a terrible thing:
>tjla@guvfybir.qlaqaf.bet (Gwyn Judd) writes:
>
>> I was shocked! How could Russ Jones <russ_jones@rac.ray.com>
>> say such a terrible thing:
>>
>> >Coincidence? None of these has anything to do with Perl or pi, but I
>> >really would like to get some Perl versions of pi calculations, the
>> >more screwy the better. Anno's already suggested the "dropping
>> >buckshot onto a circle" method.
>>
>> Can I just say, that method sucks. I remember doing that for a class in
>> Numerical Analysis once. I seem to recall having to do 1000000
>> iterations to get something like 3dp.
>
>Would that be the O(N^1/2) convergence of typical Monte Carlo methods
>that you are vaguely remembering?
Something like that. Thanks for the tips.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
The new Congressmen say they're going to turn the government around. I
hope I don't get run over again.
------------------------------
Date: Tue, 06 Mar 2001 22:26:59 GMT
From: jmcnamara@cpan.org (John McNamara)
Subject: Re: pi day
Message-Id: <3aa563ec.1883792@news1.eircom.net>
Ar 6 Mar 2001 07:03:41 -0000, do scriobh Jonathan Stowe
<gellyfish@gellyfish.com>:
>On Mon, 05 Mar 2001 16:30:14 -0000 Greg Bacon wrote:
>> Don't forget that it's also the birthday of Albert Einstein, Billy
>> Crystal, and noted Perl plinker Greg Bacon. Send Guinness. :-)
>I didnt think there was an implementation of the Network Guinness Transport
>Protocol yet.
Guinapster anyone?
John.
--
------------------------------
Date: Tue, 06 Mar 2001 12:45:52 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: RFC: FAQ3 update -- Using less memory
Message-Id: <3AA53060.EFA882D9@home.com>
Malcolm Dew-Jones wrote:
>
> On the issue of memory, you should be careful when using map or grep.
> This may not be a problem anymore, but in earlier versions
> (probably 5.003 or 5.004), it appeared that map and grep would
> potentially cause an entire file to be slurped.
>
> -1- @lines_wanted = grep {m/whatever/} <FILE> ;
Good point. It still does this in 5.6, which makes perfect sense, as map
and grep both expect a list. It would require some special magic to make
this loop over <FILE> instead of slurping it.
-mjc
------------------------------
Date: 6 Mar 2001 18:57:25 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: RFC: FAQ3 update -- Using less memory
Message-Id: <983bul$lbn$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Malcolm Dew-Jones
<yf110@victoria.tc.ca>],
who wrote in article <3aa52167@news.victoria.tc.ca>:
> On the issue of memory, you should be careful when using map or grep.
> This may not be a problem anymore, but in earlier versions (probably 5.003
> or 5.004), it appeared that map and grep would potentially cause an entire
> file to be slurped.
Since map and grep have no relationship to files, this is meaningless
> -1- @lines_wanted = grep {m/whatever/} <FILE> ;
Here <FILE> is in an array context.
Hope this helps,
Ilya
------------------------------
Date: 6 Mar 2001 12:17:47 -0800
From: yf110@victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: RFC: FAQ3 update -- Using less memory
Message-Id: <3aa545eb@news.victoria.tc.ca>
Malcolm Dew-Jones (yf110@victoria.tc.ca) wrote:
(snip)
: On the issue of memory, you should be careful when using map or grep.
: This may not be a problem anymore, but in earlier versions (probably 5.003
: or 5.004), it appeared that map and grep would potentially cause an entire
: file to be slurped.
: I forget the exact reason I tested this and the exact syntax of my tests,
: but from memory they were similar to these examples
: -1- @lines_wanted = grep {m/whatever/} <FILE> ;
: -2- while (<FILE>) { push @lines_wanted , $_ if m/whatever/ }
: I could bring my machine to a grinding halt by running -1- on very large
: files. It appeared from the OS memory stats that the entire file must
: have been slurped. -2- had no such problem.
: This was probably on 5.003 or 5.004.
It has been pointed out to me that the above behaviour has nothing to do
with map or grep. It is because <FILE> is used in an array context, and
is therefore simply a slurp.
However, the point still remains.
Whereas a shell script might sensibly use something like this...
E.g.
make_data | grep condition | cut columns > newfile
which doesn't need much memory,
the intuitively equivalent perl
E.g.
@newlines = map {something} grep {condition} <FILE> ;
may not be a good idea because it may use lots of memory.
------------------------------
Date: Tue, 06 Mar 2001 21:57:22 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: RFC: FAQ3 update -- Using less memory
Message-Id: <63dp6.12767$Ok4.1760956@news1.rdc1.ct.home.com>
In comp.lang.perl.misc Malcolm Dew-Jones <yf110@victoria.tc.ca> wrote:
> ...is used in an array context...
I should point out that there's no such thing as array context in
perl--it's either scalar or list. (Ilya mis-spoke when he used
"array context" earlier)
Dan
------------------------------
Date: 6 Mar 2001 20:59:07 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Submitting Forms from Code
Message-Id: <983912159.2772@itz.pp.sci.fi>
In article <slrn9a65hb.qa.tjla@thislove.dyndns.org>, Gwyn Judd wrote:
>
>I think it would be a service to brian d foy if everyone went out and
>bought a bigger monitor.
It would definitely be a service to me if someone went out and bought me
a bigger monitor. Not having to poke the contrast adjuster with a small
screwdriver to make it work would also be an improvement..
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"Fuck, it's people like that that make me wish I had a bazooka. But I
digress." -- Mark 'Kamikaze' Hughes in the monastery
Please ignore Godzilla / Kira -- do not feed the troll.
------------------------------
Date: Tue, 6 Mar 2001 11:06:33 -0800
From: "Mahesh A" <maheshasolkar@yahoo.com>
Subject: Re: What's wrong with (remedial)...
Message-Id: <taad9rhbeagt3e@corp.supernews.com>
"Brandon Thornburg" <centreman_19@yahoo.com> wrote in message
news:983adb$bva$1@fremont.ohsu.edu...
> Ok, this should be ridiculously easy to figure out, but maybe there's
> something about the OR statements I'm just missing. I'm just a beginner
> here, folks.
>
> if ($in{degree1} ne "B.S."||"B.A."||"A.A."||"A.S.") {
> print STDOUT ", $in{degree1}";
> }else{
> print STDOUT "";
> }
May be you can match the following pattern in your degree string...
($in{degree1} =~ /^(B\.S|B\.A|A\.A|A\.S)\.$/i)
But that does not implement your...
if ((Deg ne A)||(Deg ne B)||...)
... it comes close to ...
if ((Deg eq A)||(Deg eq B)||...)
If you want to skip the use of regex, you may use...
if (($degree ne "B.S.")||($degree ne "B.A.")||($degree ne "A.A.")||($degree
ne "A.S.")) {}
But I doubt the logical correctness of this "ne" and '||' sequence. Its
always going to be true - do you mean && ?
M.
------------------------------
Date: Tue, 6 Mar 2001 11:21:43 -0800
From: "Brandon Thornburg" <centreman_19@yahoo.com>
Subject: Re: What's wrong with (remedial)...
Message-Id: <983dhj$cke$1@fremont.ohsu.edu>
> But I doubt the logical correctness of this "ne" and '||' sequence. Its
> always going to be true - do you mean && ?
>
> M.
I don't THINK I do, but you can help me. Basically, the Degrees the people
filling out this form can be: B.S., B.A., A.A., A.S., M.S., M.A., Ph.D.,
M.D., D.O....everyone gets to have a trailing degree after their name except
the first four. Therefore, the four degrees I've listed are the ones that
$in{degree1} should not equal in order to print itself out. But it's NEVER
going to equal B.S.&&B.A.&&A.A.&&A.S., because there's only one degree
entered, so ($in{degree1} ne "1"&&"2"&&"3"&&"4") should always be true,
right? Or am I guilty of using logic? What I want to say, in English, is
this: "If degree #1 entered by the user does NOT equal B.S., B.A., A.A., or
A.S., then print degree #1. otherwise, print nothing.
Every bit of info you give me helps me a lot, so thank you in advance!
------------------------------
Date: Tue, 6 Mar 2001 11:52:55 -0800
From: "Mahesh A" <maheshasolkar@yahoo.com>
Subject: Re: What's wrong with (remedial)...
Message-Id: <taag0orb24t374@corp.supernews.com>
"Brandon Thornburg" <centreman_19@yahoo.com> wrote in message
news:983dhj$cke$1@fremont.ohsu.edu...
> right? Or am I guilty of using logic? What I want to say, in English, is
> this: "If degree #1 entered by the user does NOT equal B.S., B.A., A.A.,
or
> A.S., then print degree #1. otherwise, print nothing.
I agree with what you say in english. The 'or' that you use in this
scentence seems to confuse you. Lets break your scentence up into
fragments...
1. If degree #1 entered by the user does NOT equal B.S
2. If degree #1 entered by the user does NOT equal B.A
3. If degree #1 entered by the user does NOT equal A.A
4. If degree #1 entered by the user does NOT equal A.S
You want the degree to be printed only if ALL the statements are TRUE,
right? The logical operator which returns true only if ALL the operands are
TRUE is AND. That lead me to say that a better sequence would be that of
"ne" and "&&".
I usually follow a more straight forward approach to these situations...
1. Match the string : Not necessarily 'pattern matching', I mean identify
the string that you WANT.
2. Do the DOs in if and DONTs in else blocks.
In your case,
if (($degree eq "B.S.")
||($degree eq "B.A.")
||($degree eq "A.A.")
||($degree eq "A.S.")) {
# Nothing
} else {
# Print the degree, they want it to be after their names.
}
I think this approach makes things easy to read and they look more logical.
What I get from your comparitively-complex-condition-statement is that you
are some how trying to use,
if () {;}
instead of
if () {;} else {;}
to save some lines of code. I'd rather write a few lines of code than making
the code difficult to read - unless I am writing my YAPH signature !!
All the above are my personal preferences, they might not best ways to do
things.
M.
------------------------------
Date: 06 Mar 2001 12:53:37 -0600
From: Ren Maddox <ren@tivoli.com>
Subject: Re: What's wrong with (remedial)...
Message-Id: <m3snkqbufi.fsf@dhcp9-175.support.tivoli.com>
On Tue, 6 Mar 2001, centreman_19@yahoo.com wrote:
> if ($in{degree1} ne "B.S."||"B.A."||"A.A."||"A.S.") {
You just cannot combine a comparison operator ("ne") and a Boolean
operator ("||") in that way. Assuming you want to test that it
matches none of them, try:
if ($in{degree1} ne "B.S." && $in{degree1} ne "B.A." &&
$in{degree1} ne "A.A." && $in{degree1} ne "A.S.") {
Or, for this particular example, you could simplify it with a regex:
if ($in{degree1} !~ /^[BA]\.[AS]\.$/) {
Maybe you would like something like:
if (! grep { $in{degree1} eq $_ } qw/B.S. B.A. A.A. A.S./) {
which is more concise than the first and more flexible than the
second.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Tue, 6 Mar 2001 15:29:26 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: What's wrong with (remedial)...
Message-Id: <slrn9aai56.8d7.tadmc@tadmc26.august.net>
Peter L. Berghold <peter@uboat.berghold.net> wrote:
>On Tue, 6 Mar 2001 10:28:15 -0800,
> Brandon Thornburg <centreman_19@yahoo.com> wrote:
>>if ($in{degree1} ne "B.S."||"B.A."||"A.A."||"A.S.") {
>
>That just plain ain't gonna work....
>
>Try this instead:
>
>my %degList = (
> 'B.S.' => 1,
> 'B.A.' => 1,
> 'A.A.' => 1,
> 'A.S.' => 1
>);
>
>if ( $degList{$in{$degree1}} ) {
> --- whatever....
>
>
>There are probably (no doubt) more clever ways of doing this
I dunno about clever content, but grep() is for "filtering a list"
which is what we could do here:
unless ( grep $_ eq $in{degree1}, qw/B.S. B.A. A.A. A.S./ ) {
print "Wassa matta? You don't have one of the allowed degrees.\n";
}
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 6 Mar 2001 13:34:51 -0800
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: What's wrong with (remedial)...
Message-Id: <3aa557fb$1@news.microsoft.com>
"Ren Maddox" <ren@tivoli.com> wrote in message
news:m3snkqbufi.fsf@dhcp9-175.support.tivoli.com...
> On Tue, 6 Mar 2001, centreman_19@yahoo.com wrote:
>
> > if ($in{degree1} ne "B.S."||"B.A."||"A.A."||"A.S.") {
>
> You just cannot combine a comparison operator ("ne") and a Boolean
> operator ("||") in that way.
[...]
Of course you can.
The "ne" has a higher priority than the ||, therefore first the expression
$in{degree1} ne "B.S."
will be evaluated, yielding either true or false.
The || is left-associative, therefore the next term to evaluate is (using
[true|false] as a notation to indicate either true or false):
[true|false] || "B.S"
"B.S." is not empty, therefore it evaluates to "true" in a Boolean context:
[true|false] || true
This obviously yields "true" regardless of the value the '$in{degree1} ne
"B.S." '.
And the next reduction steps are
true || "B.A."||"A.A."||"A.S."
true || true "||"A.A."||"A.S."
true || "A.A."||"A.S."
true || true "||"A.S."
true || "A.S."
true || true
true
As you can see it is valid code, although pretty useless.
jue
------------------------------
Date: Tue, 06 Mar 2001 22:22:50 GMT
From: "David Charles" <administrator@playauction.com>
Subject: Re: What's wrong with (remedial)...
Message-Id: <_qdp6.348163$f36.12134132@news20.bellglobal.com>
Hello,
The reason is that you are mixing "ne" with "||" (which is allowed), but you
are forgetting about precedence as Jurgen was saying; All you have to do is
add parentheses as such:
if ($answer ne ("B.S." || "B.A." || "A.A." || "A.S.")) {
print $answer;
}
Now if you try it, it should work as you wanted. 8^)
Hope this helps,
David Charles
"Brandon Thornburg" <centreman_19@yahoo.com> wrote in message
news:983adb$bva$1@fremont.ohsu.edu...
> Ok, this should be ridiculously easy to figure out, but maybe there's
> something about the OR statements I'm just missing. I'm just a beginner
> here, folks.
>
> if ($in{degree1} ne "B.S."||"B.A."||"A.A."||"A.S.") {
> print STDOUT ", $in{degree1}";
> }else{
> print STDOUT "";
> }
>
> Now, I should say here that I've tried lots of different permutations of
> this, including extra parentheses, leaving off the else statement, etc.
and
> yet somehow the first statement is always the one returned. (This is CGI,
by
> the way, so if there's a better newsgroup to post to please let me know).
>
>
------------------------------
Date: 6 Mar 2001 22:24:14 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: What's wrong with (remedial)...
Message-Id: <983917454.73963@hpvablab.cup.hp.com>
"Brandon Thornburg" <centreman_19@yahoo.com> writes:
>Ok, this should be ridiculously easy to figure out, but maybe there's
>something about the OR statements I'm just missing. I'm just a beginner
>here, folks.
>
>if ($in{degree1} ne "B.S."||"B.A."||"A.A."||"A.S.") {
> print STDOUT ", $in{degree1}";
>}else{
> print STDOUT "";
>}
This may be in line more with how you're thinking about the problem:
#!/usr/bin/perl -w
use strict;
use Quantum::Superpositions;
my @data = <DATA>;
foreach(@data) {
chomp();
print "$_\n" if($_ eq any("B.S.", "B.A.", "A.A."));
}
print "or did you want..\n";
foreach(@data) {
chomp();
print "$_\n" if($_ ne all("B.S.", "B.A.", "A.A."));
}
__DATA__
B.S.
B.A.
A.A.
A.S.
X.Y.
--
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant | I speak for me, | 19055 Pruneridge Ave.
Development Alliances Lab| *not* HP | MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014
------------------------------
Date: Tue, 6 Mar 2001 14:36:05 -0800
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: What's wrong with (remedial)...
Message-Id: <3aa56655$1@news.microsoft.com>
"David Charles" <administrator@playauction.com> wrote in message
news:_qdp6.348163$f36.12134132@news20.bellglobal.com...
> The reason is that you are mixing "ne" with "||" (which is allowed), but
you
> are forgetting about precedence as Jurgen was saying; All you have to do
is
> add parentheses as such:
>
> if ($answer ne ("B.S." || "B.A." || "A.A." || "A.S.")) {
> print $answer;
> }
>
> Now if you try it, it should work as you wanted. 8^)
Actually I doubt it. Your suggestion would evaluate to
$answer ne (true || true || true || true)
or
$answer ne (true)
which can more easily be written as
!$answer
I don't think this is what the OP meant.
jue
------------------------------
Date: Tue, 6 Mar 2001 16:25:27 -0500 (EST)
From: blatnoi@webtv.net (=?ISO-8859-1?Q?BigB=90=90=99?=)
Subject: Whats This ?
Message-Id: <20038-3AA555C7-44@storefull-618.iap.bryant.webtv.net>
can anyone tell me???
i got myself a script from a place called Anaconda - Now this is a
search engine script that shows results on a subject on my site - my
question??????
is the place that gave out the script -- getting paid a commission --
after someone uses the results page??? i'm curious - at least they
should mention it if they are -
heres the submit form -
http://i0us.virtualave.net/anancon/m.html modules
http://i0us.virtualave.net/anancon/ap_freesearch.apl
http://i0us.virtualave.net/anancon/apexecutive.apl
when the RESULTS come up - everytime - the link urls of the results
(when clicked on) have somethig like an affiliate ID??
example - type in --- perl ----Submit
then you get results - each result seems to have an affiliate id od
anaconda name on it - or something with the anaconda name on it like an
affiliate id - can anyone tell me is it an affiliate id ???
they should tell me about it before i use it - i think i should know.
Thank You
Eliot
------------------------------
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 V10 Issue 429
**************************************