[9783] in Perl-Users-Digest
Perl-Users Digest, Issue: 3376 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 6 11:36:41 1998
Date: Thu, 6 Aug 98 08:00:27 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 6 Aug 1998 Volume: 8 Number: 3376
Today's topics:
Re: $form_data{'$variable'} question (Harold Bamford)
Re: Argh! (Andrew M. Langmead)
Chicago Perl Mongers meeting (Jim Allenspach)
Re: comp.lang.perl.announce redux (Abigail)
Re: comp.lang.perl.announce redux <merlyn@stonehenge.com>
Re: Executing a Perl script from a hyperlink <rickryan@mindspring.com>
Extracting data from Lotus Notes with Perl? jfritsche@my-dejanews.com
Re: gethostbyaddr (Matt Knecht)
Re: help a newbie, please! (Larry Rosler)
Re: hiding user input (Greg Bacon)
Re: hiding user input (Abigail)
Need pm's to access IIS4's MetaBase <sunder@brainlink.com>
Pattern matching <dgl@offis.lu>
Re: perl and sendmail mighani@my-dejanews.com
Re: Perl Docs.. forget the original post (Gary L. Burnore)
Re: Perl Docs.. forget the original post (Chris Nandor)
Re: Perl/Tk-Win32? dturley@pobox.com
Re: Proper Pattern Match <jdf@pobox.com>
Re: push @list, nullsub() doesn't push anything--why no (Mike Stok)
Re: push @list, nullsub() doesn't push anything--why no <quednauf@nortel.co.uk>
Re: push @list, nullsub() doesn't push anything--why no <jdf@pobox.com>
Re: Q:How to compile a perl script under PerlW32? <jdw@dev.tivoli.com>
Re: Q:How to compile a perl script under PerlW32? (Clinton Pierce)
Re: Variable Length & Memory? <matt@pcr7.pcr.com>
Re: Variable Length & Memory? (Andrew M. Langmead)
Re: Variable Length & Memory? <matt@pcr7.pcr.com>
Re: X-file (?=...), case postponed. (Abigail)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Aug 1998 14:23:57 GMT
From: hbamford@marconi.ih.lucent.com (Harold Bamford)
Subject: Re: $form_data{'$variable'} question
Message-Id: <6qce9t$mpm@ssbunews.ih.lucent.com>
>> I have a form with several text fields. These fields are named
>> editcol1,editcol2,editcol3 ... and so on.
>>
>> I want to check if these fields are blank, if they are not then the value of
>> $new_data will equal the value of $form_data{'editcoln'} ... where n is the
>> number 1,2,3...
>>
>> I am trying to set this up in a loop such as:
>>
>> for($i=1,$i<=$total,$i++) { # $total is set earlier
>> $new_data = $form_data{'editcol$i'};
Seems like the first thing to happen should be replacing
the 'editcol$i' with "editcol$i" so that the $i is interpolated.
--
-- Harold Bamford
mailto:hbamford@lucent.com
(630)713-1351
------------------------------
Date: Thu, 6 Aug 1998 14:24:14 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Argh!
Message-Id: <Ex9uoE.HsF@world.std.com>
cberry@cinenet.net (Craig Berry) writes:
>Second, how is that better? Seems that @what will still end up requiring
>the same amount of memory in either case, and that the overhead for
>explicitly pushing each line will be larger than the overhead of doing a
>list-context <>. I'd Benchmark this, but can't work out a good way to set
>up the test.
It probably depends a lot on the size of the data file. The
"@what = <A>" will allocate memory for the list context "<A>", then
allocate memory for the assignment to @what, copy it all, and then
release the memory for the list created by "<A>". The
"push @what $_, while <A>" will allocate memory for each line in the
file, and extend the memory location for @what array, allocate memory
for the new element of @what, then free the memory for the current
line in "A". Since the memory freed is not given back to the OS, but
just saved for reuse, the next line in A will probably just use the
recently freed line.
So in "@what = <A>" you may get to huge memory allocation calls to the
OS, but in "push @what $_ while <A>" you get at most a bunch of calls
for memory with the total equal to about half of the list context one,
plus one line. With most malloc implementations, it will try to avoid
asking for memory often by getting more memory than it needs to
satisfy the current memory request, somewhat optimizing the extending
of the what array in the "push" version.
The reason why this is hard to show with the Benchmark module, is that
all the memory that is needed is allocated in the first iteration of
the first code snippet, and after that, the program has already asked
the OS for all of the memory it needs for the operation. The rest of
the iterations of the rest of the tests just reuse the memory from
perl's internal pool of memory. (Except maybe for MacPerl, which I
think is given a fixed memory allotment when the program starts, so
its malloc() will never ask the OS for more memory. And in that case,
you may get situations where the memory friendly "push" will work and
the list context version will fail.)
--
Andrew Langmead
------------------------------
Date: 6 Aug 1998 09:34:42 -0500
From: jima@MCS.COM (Jim Allenspach)
Subject: Chicago Perl Mongers meeting
Message-Id: <6qceu2$hrt@Venus.mcs.net>
The Chicago PM chapter will be having its next meeting on Monday,
August 10, at the Pick Me Up Cafe (3408 N. Clark), starting at 7:30.
Information on the group or on how to get to the cafe can be found at the
group's Website, http://chicago.pm.org/ .
jma
------------------------------
Date: 6 Aug 1998 14:16:14 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: comp.lang.perl.announce redux
Message-Id: <6qcdre$1pg$1@client3.news.psi.net>
Russ Allbery (rra@stanford.edu) wrote on MDCCCI September MCMXCIII in
<URL: news:m31zquslfc.fsf@windlord.Stanford.EDU>:
++ Damien SAUTEREAU <dsautereau@magic.fr> writes:
++
++ > I guess clpa has no equivalent in any other Perl's hierarchy. So if it
++ > has an international audience we should expect and accept non-english
++ > posting. Accepting only posts in English means refusing potentialy good
++ > Perl programming announcements. Personnaly I don't read clp* for
++ > English language but for Perl language.
++
++ I don't know if anyone has pointed this out yet, but....
++
++ de.comp.lang.perl
++ fj.comp.lang.perl
++ fr.comp.lang.perl
++ han.comp.lang.perl
++ it.comp.lang.perl
++ no.it.programmering.perl
++ relcom.comp.lang.perl
++
++ would seem to be the appropriate places to post articles about Perl in
++ German, Japanese, French, Korean, Italian, Norwegian, and Russian.
Actually, I would expect them to be appropriate places to post
articles about Perl in Germany, Japan, France, Korea, Italy, Norway
and Russia. A small, but essential difference.
++ While this is not to say that posts in other languages should be banned,
++ it does indicate that if someone is writing *primarily* in another
++ language, they'd be better served in a different hierarchy.
We are talking about the exceptional posting. I rather read just clpa
and skip the occasional posting in Italian or French, then to have to
read perl groups in various languages for the occasional there that has
world wide interest.
++ thing, all administrative business in the Big Eight related to newsgroup
++ creation is done exclusively in English because the news administrators
++ that carry these hierarchies have English in common more than any other
++ language, so people using other languages will eventually find that they
++ cannot easily participate in debate surrounding creating, removing, or
++ renaming the groups they're reading here.
++
++ Please also keep in mind that such hierarchies as de.* are often not
++ regional hierarchies, but rather are chartered as *world-wide* hierarchies
++ in the languages in question.
Well, of the 7 groups you mentioned, PSInet doesn't carry 4 of them.
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
------------------------------
Date: Thu, 06 Aug 1998 14:46:56 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: comp.lang.perl.announce redux
Message-Id: <8c90l2cgmi.fsf@gadget.cscaper.com>
>>>>> "Abigail" == Abigail <abigail@fnx.com> writes:
Abigail> Well, of the 7 groups you mentioned, PSInet doesn't carry 4 of them.
That's not surprising, given the interesting delay PSInet had in
creating comp.lang.perl.moderated. Is it even carrying it yet?
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Thu, 6 Aug 1998 09:45:33 -0500
From: "Rick Ryan" <rickryan@mindspring.com>
Subject: Re: Executing a Perl script from a hyperlink
Message-Id: <6qcflq$chs$1@camel18.mindspring.com>
Thanks guys for the replies.
Bob Gwynne wrote in message <6qc0i8$d9e$1@gaia.ns.utk.edu>...
>Use CGI.pm. See Official Guide to Programming with CGI.pm, pp. 117 ff.
>
>Bob Gwynne
>
>Rick Ryan wrote in message <6qba0v$n9l$1@camel25.mindspring.com>...
>>I have a page that has an <img=> command that points back to a gif file.
Is
>>there any way to make it point to and execute a perl script (without a
>>submit form)?
>>
>>Thanks, oh gurus of the Perl!
>>
>>rickryan@mindspring.com
>>
>>
>>
>>
>
>
------------------------------
Date: Thu, 06 Aug 1998 14:44:56 GMT
From: jfritsche@my-dejanews.com
Subject: Extracting data from Lotus Notes with Perl?
Message-Id: <6qcfh8$ji9$1@nnrp1.dejanews.com>
We have dumped Lotus Notes as a corporate app, but have quite a bit of data
that we need to port to MS Access/MS SQL tables. Most of it we are able
to export. The problem appears to be Rich Text fields. Apparently, these
cannot be added to views and thus cannot be exported. Is there a way to
connect to the Notes database so that a perl program could read these fields
and dump them to a text file?
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Thu, 06 Aug 1998 14:31:21 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: gethostbyaddr
Message-Id: <Z6jy1.1734$NJ5.6567515@news2.voicenet.com>
George Cushing <gcushing@exchange.nih.gov> wrote:
>I am trying to get the host name if Iknow the ip address. gethostname
>works fine. While using gethostbyaddr, you must enter the ip address
>and address type. I do not know what to enter for address type. The ip
>address is "209.67.73.165" and the address
>type should be ?????
Quickly to the point:
use Socket;
$adrs = '208.201.239.48';
$name = gethostbyaddr(pack('C4', split /\./, $adrs), AF_INET);
Now, off on a tangent.
First off, the only reason I know this is because I've used the function
gethostbyaddr in C. The man page for the C function tells you what you
have to include, and even tells you a little bit about the defines (Not
much, though). Unfortunately (I dont' want to add fuel to the FAQ/doc
complainers fire, but...) perdoc -f gethostbyaddr doesn't help much if
you don't already know what to do.
Granted the information is there. In perldoc Socket, and in other parts
of perlfunc (getpeername, oddly enough), but the gethost* subs really
should at least mention to 'use Socket'.
And, as long as I'm just mouthing off (And not submitting patches :) ) about
the docs a helpful tip may be to include something along the lines of:
gethostbyaddr. You want AF_INET as the second argument 99% of the time.
No, really. It's true. We can't tell you why. Don't even think about
using PF_INET even though it's defined as the same as AF_INET. Don't
bother looking this up. Trust us. If you really want to know that
badly, go read Stevens' book. If you don't understand all of Stevens,
go see figure 1...
After being wooed by the DWIMer, I get upset when it doesn't work.
--
Matt Knecht - <hex@voicenet.com>
------------------------------
Date: Thu, 6 Aug 1998 06:54:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: help a newbie, please!
Message-Id: <MPG.1033555f19d980a19897bb@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <35C98148.363A2CE6@nortel.co.uk> on Thu, 06 Aug 1998 11:11:20
+0100, F.Quednau <quednauf@nortel.co.uk> says...
> Jianjun Feng wrote:
...
> > The first line in the script is written for unix system: something like
> > " #!/usr/bin/perl". How can i do the same thing for win95, or can i do
> > it in win95 at all?
...
> ... There is no such thing as the shebang line on that system.
Yes, there is. It doesn't control where the perl resides. However,
switches like '-w' *are* interpreted when the program is executed.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 6 Aug 1998 14:26:30 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: hiding user input
Message-Id: <6qceem$15f$3@info.uah.edu>
Will you ever learn to limit the lengths of your lines?
In article <35C95C4C.E9A7EB80@dead.end.com>,
no.unsoliciteds@dead.end.com writes:
: Greg Bacon wrote:
: > The moderated group doesn't replace this group! Being a *.misc group
: > makes it the catchall for topics related to Perl that don't quite fit
: > in the other groups (or topics for which no one can agree on the proper
: > group). This group is not obsolete. This group still needs to be
: > useful. FAQ flooding and usefulness are forces in opposing directions.
:
: Again you contradict yourself in a post Greg - if misc means the group i
: cover topics that don't fit in the other perl groups please tell me wher
: comp.lang.perl.newbies or comp.lang.perl.faq are. If these news groups d
: exist then where should the topics that would have gone to them go?
The fact that this group is a catchall does not mean anything goes.
This group has a FAQ, and people are expected to consult it before
posting. This is the case for every group that has a FAQ. What would
be the point of clp.newbies? Why would new users post their questions
there when experts are probably elsewhere?
: AS you are one of a small group who seems to have a problem - why don't
: and the small group go off where you'll be happier - like comp.lang.perl
That claim has no basis in fact. Please share with us how you arrived
at the conclusion that I am a misogynist.
Greg
--
If you view your problem closely enough you will recognize yourself as part of
the problem.
------------------------------
Date: 6 Aug 1998 14:41:45 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: hiding user input
Message-Id: <6qcfb9$20k$1@client3.news.psi.net>
Russ Allbery (rra@stanford.edu) wrote on MDCCCI September MCMXCIII in
<URL: news:m3u33qnyn4.fsf@windlord.Stanford.EDU>:
++ birgitt <birgitt@my-dejanews.com> writes:
++
++ > Oh, I would agree strongly, but I don't understand how Dejanews makes
++ > money of the archives.
++
++ > I got access to My DejaNews at no other additional cost than I have to
++ > pay to get www access through my local ISP. Who pays for me being able
++ > to access the archives ? From whom does DejaNews gets money to provide
++ > them ?
++
++ Advertisers. The banner ads are paying for it.
Oh, that's fine with me. They are trivial to filter. :)
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Thu, 06 Aug 1998 10:29:39 -0400
From: Ray Arachelian <sunder@brainlink.com>
Subject: Need pm's to access IIS4's MetaBase
Message-Id: <35C9BDD3.28733278@brainlink.com>
With IIS4, Microsoft (puke) changed the way that IIS web sites are registered.
They're now in some weird proprietary database called the MetaBase. Anyone
have code that will let me create IIS sites? In particular I need to mass
create lots of virtual web servers, each with their own htdocs, cgi-bin dirs,
different security settings, different IUSR_WEB accounts, etc... :(
In other words, a nightmare to do from the MMC... If there's any perl module
that will let me access this evil thing, I sure could use it. :( Please Help!
--
=====================================Kaos=Keraunos=Kybernetos==============
.+.^.+.| Ray Arachelian |Prying open my 3rd eye. So good to see |./|\.
..\|/..|sunder@sundernet.com|you once again. I thought you were |/\|/\
<--*-->| ------------------ |hiding, and you thought that I had run |\/|\/
../|\..| "A toast to Odin, |away chasing the tail of dogma. I opened|.\|/.
.+.v.+.|God of screwdrivers"|my eye and there we were.... |.....
======================= http://www.sundernet.com ==========================
------------------------------
Date: Thu, 06 Aug 1998 15:59:30 +0200
From: David Gallone <dgl@offis.lu>
Subject: Pattern matching
Message-Id: <35C9B6C1.8208D4D@offis.lu>
I use the option "ignore case (i)" in my pattern matching (?i) and
I would know if this option is specified for all of the pattern?
$string =~ s/(?i)(IMG|INPUT)\s*([^>]*?)\s*(SRC)\s*=\s* ...etc
The option ?i is specified for IMG|INPUT or all the pattern?
Thanks in advance,
David GALLONE
------------------------------
Date: Thu, 06 Aug 1998 14:41:07 GMT
From: mighani@my-dejanews.com
Subject: Re: perl and sendmail
Message-Id: <6qcfa3$jfc$1@nnrp1.dejanews.com>
In article <35c8bc67.0@news.destek.net>,
"Steve Goodyear" <sgoodyear@genxsys.com> wrote:
> how do I pass an email message to perl for parsing?
> I realize I can alias a program in the aliases file, but i'm not sure how it
> passed the message to a program.
>
>
Hi Steve,
the message will be available on the standard input
e.g. @message=<STDIN>
note that the variable is scalar
Greetings from Germany
Masiar
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Thu, 06 Aug 1998 14:18:58 GMT
From: gburnore@databasix.com (Gary L. Burnore)
Subject: Re: Perl Docs.. forget the original post
Message-Id: <35d3bb1d.212528990@nntpd.databasix.com>
On Thu, 06 Aug 1998 09:50:43 -0400, in article <35C9B4B3.37E6@min.net>, John
Porter <jdporter@min.net> wrote:
>no.unsoliciteds@dead.end.com wrote:
>>
>> All I can say is this - if the gurus had had bad tempered, ecclectic, obtuse
>> and sometimes downright abusive lecturers with bad communication skills
>> perhaps they would have a different attitude now.
>
>The implication is that the "gurus" have, as a result, bad communication
>skills. But just you can't (or won't) read doesn't mean they can't
>write.
>Your disparagement is very unjustified, and is very insulting.
>What have *you* done for the Perl community?
>
You're again suggesting that because someone has done something for the Perl
community they have a right to be rude.
--
I DO NOT WISH TO RECEIVE EMAIL IN REGARD TO USENET POSTS
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
| ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
DOH! | ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
| ][3 3 4 1 4 2 ]3^3 6 9 0 6 9 ][3
Special Sig for perl groups. | Official Proof of Purchase
===========================================================================
------------------------------
Date: Thu, 06 Aug 1998 10:26:04 -0400
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Perl Docs.. forget the original post
Message-Id: <pudge-0608981026040001@192.168.0.3>
In article <35d3bb1d.212528990@nntpd.databasix.com>,
whatpartofdontemailme@dontyouunderstand wrote:
# On Thu, 06 Aug 1998 09:50:43 -0400, in article <35C9B4B3.37E6@min.net>, John
# Porter <jdporter@min.net> wrote:
#
# >no.unsoliciteds@dead.end.com wrote:
# >>
# >> All I can say is this - if the gurus had had bad tempered, ecclectic,
obtuse
# >> and sometimes downright abusive lecturers with bad communication skills
# >> perhaps they would have a different attitude now.
# >
# >The implication is that the "gurus" have, as a result, bad communication
# >skills. But just you can't (or won't) read doesn't mean they can't
# >write.
# >Your disparagement is very unjustified, and is very insulting.
# >What have *you* done for the Perl community?
# >
#
# You're again suggesting that because someone has done something for the Perl
# community they have a right to be rude.
No, I think the implication is that if you have NOT done anything for the
Perl community (this means you), then you do NOT have a right to be rude,
and that we grant certain leniencies to people who do things for the
community. When Tom or Abigail is rude, the may get chastised, but they
are not dismissed. When you are rude, you are dismissed.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Thu, 06 Aug 1998 14:12:37 GMT
From: dturley@pobox.com
Subject: Re: Perl/Tk-Win32?
Message-Id: <6qcdkl$hfh$1@nnrp1.dejanews.com>
In article <6qanvp$j2j@newsserver.trl.OZ.AU>,
> Can anyone tell me if the Tk package runs under Win95? 'use Tk' fails
> on the standard bindist5.004_02 and the Tk package off CPAN seems to
> require UNIX.
Works here. I seem to recall when I installed the distribution it ran a test
Tk/perl script.
Check the examples inluded with the distribution.
cheer,
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 06 Aug 1998 10:30:21 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: mike@newfangled.com
Subject: Re: Proper Pattern Match
Message-Id: <u33qjfg2.fsf@mailhost.panix.com>
"Michael S. Brito, Jr." <mike@newfangled.com> writes:
> foreach $i (@indata) {
"$i" is not a good name for that variable; better would be, say,
"$line". Also, why is the whole file in an array? Why not
while (<INDATA>) {
> chop($i);
You should consider using chomp() instead, since that would allow for
an improperly terminated file.
> ($place,$addr1,$addr2,$addr3,$city,$state,$zip,$phone) =
> split(/\|/,$i);
It might be helpful to check your assumptions here, by saying
print "\$place contains <$place>\n";
> foreach $dealer (@dealer) {
> if ($place !~ /\Q$dealer\E/ix) {
You're checking to see if $place does *not* contain $dealer. Is that
really what you intend?
> Note the usage of \Q, \E and /ix...... Is /x required???
Nope.
> #!/usr/bin/perl
You *really* want to be using the -w switch while debugging your
script. See DejaNews for some friendly discussions about whether you
should leave it in the production script.
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
[etc.]
You *really* want to use CGI.pm instead.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf/
------------------------------
Date: 6 Aug 1998 14:44:18 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: push @list, nullsub() doesn't push anything--why not?
Message-Id: <6qcfg2$om@news-central.tiac.net>
In article <877m0mtela.fsf@couatl.uchicago.edu>,
stephen farrell <sfarrell@farrell.org> wrote:
>
>
>#!/usr/local/bin/perl5
>
>sub nullsub { }
>
>push @list, nullsub();
>push @list, undef;
>
>warn scalar(@list);
>
>
>...why does this give 1 and not 2?? thanks
Because when you return nothing the actual thing returned is context
dependent - in list context you get an empty list back, in scalar context
you get an undefined scalar back (and in void context nothing's
returned...):
DB<1> sub nullsub {}
DB<2> $scalar = 'x'; $scalar = nullsub; print defined $scalar
DB<3> @list = (); @list = nullsub; print scalar @list
0
DB<4> @list = (); @list = scalar nullsub; print scalar @list
1
DB<5> X list
@list = (
0 undef
)
This is documented in perlfunc:
return EXPR
return Returns from a subroutine, eval(), or do FILE with the value of the
given EXPR. Evaluation of EXPR may be in a list, scalar, or void
context, depending on how the return value will be used, and the
context may vary from one execution to the next (see wantarray()).
If no EXPR is given, returns an empty list in a list context, an
undefined value in a scalar context, or nothing in a void context.
(Note that in the absence of a return, a subroutine, eval, or do
FILE will automatically return the value of the last expression
evaluated.)
This means that if you have a routine which returns "nothing" in an error
situation to indicate failure and a logically true value in scalar context
or a list of 1 or more values in list context on success you can detect
failure like this
unless (myfunc) {
...
}
unless (($val1, $val2) = myfunc) {
...
}
(If you return an undefined value e.g. return undef; then the array
assignment will assign an element)
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Thu, 06 Aug 1998 15:40:38 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: push @list, nullsub() doesn't push anything--why not?
Message-Id: <35C9C066.AB9E7960@nortel.co.uk>
stephen farrell wrote:
>
> #!/usr/local/bin/perl5
>
> sub nullsub { }
>
> push @list, nullsub();
> push @list, undef;
sub nullsub { return }
push @list, nullsub();
push @list;
push @list,;
push @list,();
They all parse allright in my Perl. The most explabnatory is the last
one, which pushes an empty list into the @list - array. push always
takes a list as second argument. As an empty list has zero elements,
therefore having a length of zero, and the push doc states that 'The
length of ARRAY increases by the length of LIST', scalar @list will give
zero. With pushing undef into @list you're effectively pushing a list
with one element into @list, although that element is undef. It doesn't
really matter.
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: 06 Aug 1998 10:59:04 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: stephen farrell <sfarrell@farrell.org>
Subject: Re: push @list, nullsub() doesn't push anything--why not?
Message-Id: <r9yuje47.fsf@mailhost.panix.com>
stephen farrell <sfarrell@farrell.org> writes:
> sub nullsub { }
>
> push @list, nullsub();
> push @list, undef;
You might want to check out the use of the -D switch (documented in
perlrun) for exploring questions like this. nullsub is a stub in your
example, and puts nothing on the stack. undef, on the other hand, is
a scalar value, and takes up room on the stack. The push() op pushes
what's on the stack.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf/
------------------------------
Date: 05 Aug 1998 22:07:19 -0500
From: "Jim Woodgate" <jdw@dev.tivoli.com>
Subject: Re: Q:How to compile a perl script under PerlW32?
Message-Id: <ob3ebavme0.fsf@alder.dev.tivoli.com>
ccalam@cpccux0.cityu.edu.hk (LAM Yee-fai ALEX) writes:
> I read from newsgroup that the Perl 5.005_XX image can
> compile a perl script into native image (EXE).
in the 5.005_01 release, go to the top of your perl source directory,
then:
$ cd utils
$ perldoc perlcc.PL
should tell you everything you need to know...
--
Jim Woodgate
Tivoli Systems
E-Mail: jdw@dev.tivoli.com
------------------------------
Date: 6 Aug 1998 14:36:38 GMT
From: cpierce1@cp500.fsic.ford.com (Clinton Pierce)
To: ccalam@cpccux0.cityu.edu.hk (LAM Yee-fai ALEX)
Subject: Re: Q:How to compile a perl script under PerlW32?
Message-Id: <6qcf1m$mki1@eccws1.dearborn.ford.com>
In article <6q7363$7o45@news1.cityu.edu.hk>,
ccalam@cpccux0.cityu.edu.hk (LAM Yee-fai ALEX) writes:
>Question:
>1) What are the steps taken in order to compile a perl script?
Since you're interested in Win32, search the Web for "perl2exe".
Nice shareware (?) product that will do the trick for you.
>2) Is the procedure for compiling a perl script the same
> across difference platform? (Solaris, HP, WIN32)
No. "perl2exe" is not necessarily compiling the script. Sort of.
Perl really isn't "compilable". It's compilable only in the sense
that the run time engine knows what to do with the perl ops.
To have a TRULY compiled perl program, you need to use Malcom's
Perl to C translator in one form or another to get C code. And
then compile the C code.
>3) Is the compiled image be executed faster and takes less
> resources? (memory, CPU, disk space)?
Generally speaking: No, no and no.
This is an FAQ. Please search the Perl FAQ's to get a more
detailed answer...
--
+------------------------------------------------------------------------+
| Clinton A. Pierce | "If you rush a Miracle Man, | http://www. |
| cpierce1@ford.com | you get rotten miracles" | dcicorp.com/ |
| fubar@ameritech.net |--Miracle Max, The Princess Bride| ~clintp |
+------------------------------------------------------------------------+
GCSd-s+:+a-C++UALIS++++P+++L++E---t++X+b+++DI++++G++e+>++h----r+++y+++>y*
------------------------------
Date: 6 Aug 1998 14:09:20 GMT
From: "Matt Heusser" <matt@pcr7.pcr.com>
Subject: Re: Variable Length & Memory?
Message-Id: <01bdc139$398424a0$47eb1bcc@XSTA71.pcr.com>
>If you don't use a pathologically bad case (I imagine
>some knucklehead here posting a program that uses
>million character identifiers) any difference in memory
>would fade into the background noise.
I remember using Pascal on a Apple IIe and having
variable size limits of 8 characters - so intTester and
intTesterTwo were considered the same at compilation
time. UGH. Then came Borland Turbo Pascal, and
32-character variable names. Man, that was
"The Bomb."(*) So, I know what it means to look to
the size of you're variables and wonder "Is
CustFileRecordNumber1 going to evaluate to the
name as CustFileRecordNumber2? Let's see ...
22 characters .. that's pushing it ..."
I forget where I read it, but I think either Wall
or Scwartz wrote something like this once:
"Perl doesn't create arbitrary limits." In other
words, no one sits down with a hat and "picks out"
the maximum size for a string name, or the max.
_size_ of a string, a hash, an array, etc. These
are determined by what happens when you compile
the C Source - the limits of your processor,
operating system, and how many megs of memory
you have.
So, unless you are using perl to generate perl or
something even more esoteric, you don't have to
worry about it. Don't use variable names over 100
characters, and you'll be fine. ;-)
good luck,
Matt H.
echo JA ksh H
(*) - I still think "The Bomb" should have an entry
in the Hacker's Jargon Dictionary. I'm off to apply ...
------------------------------
Date: Thu, 6 Aug 1998 14:32:00 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Variable Length & Memory?
Message-Id: <Ex9v1C.48G@world.std.com>
"Adam Graham-Yooll" <agy@macgreg.com> writes:
>When a script is compiled all the variable names are turned into memory
>addresses. So there is no difference in the executable size or speed.
In perl, package variables are stored in a symbol table, which is just
like a hash. So those variable names still has to be around at run
time.
But I agree with others that the differences in length in variables
names is not going to have any noticable affect on the memory
footprint of a program.
--
Andrew Langmead
------------------------------
Date: 6 Aug 1998 14:55:36 GMT
From: "Matt Heusser" <matt@pcr7.pcr.com>
Subject: Re: Variable Length & Memory?
Message-Id: <01bdc14a$1ef11a60$47eb1bcc@XSTA71.pcr.com>
>If you don't use a pathologically bad case (I imagine
>some knucklehead here posting a program that uses
>million character identifiers) any difference in memory
>would fade into the background noise.
I remember using Pascal on a Apple IIe and having
variable size limits of 8 characters - so intTester and
intTesterTwo were considered the same at compilation
time. UGH. Then came Borland Turbo Pascal, and
32-character variable names. Man, that was
"The Bomb."(*) So, I know what it means to look to
the size of you're variables and wonder "Is
CustFileRecordNumber1 going to evaluate to the
name as CustFileRecordNumber2? Let's see ...
22 characters .. that's pushing it ..."
I forget where I read it, but I think either Wall
or Scwartz wrote something like this once:
"Perl doesn't create arbitrary limits." In other
words, no one sits down with a hat and "picks out"
the maximum size for a string name, or the max.
_size_ of a string, a hash, an array, etc. These
are determined by what happens when you compile
the C Source - the limits of your processor,
operating system, and how many megs of memory
you have.
So, unless you are using perl to generate perl or
something even more esoteric, you don't have to
worry about it. Don't use variable names over 100
characters, and you'll be fine. ;-)
good luck,
Matt H.
echo JA ksh H
(*) - I still think "The Bomb" should have an entry
in the Hacker's Jargon Dictionary. I'm off to apply ...
*---------------------------------------------------------------------*/
Matthew R. Heusser, Bill Development, PCR Inc.
E-mail: <Matt@pcr7.pcr.com>
Phone: (616)-554-1036
/*---------------------------------------------------------------------*/
------------------------------
Date: 6 Aug 1998 14:23:28 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: X-file (?=...), case postponed.
Message-Id: <6qce90$1pg$2@client3.news.psi.net>
F.Quednau (quednauf@nortel.co.uk) wrote on MDCCCI September MCMXCIII in
<URL: news:35C96EA7.112725B3@nortel.co.uk>:
++ Abigail wrote:
++ >
++ > F.Quednau (quednauf@nortel.co.uk) wrote lots of stuff...
++
++ > You lost it in the first step. /(?=(.*))/ does *NOT* mean zero or
++ > more characters.
++
++ ..and..
++
++ ++ What stops the whole thing ever matching the whole
++ ++ sentence for doing a split?
++
++ That's explained very clearly in the documentation related to split.
++
++
++ I'll put this to the X-files. Unexplained mysteries. Don't worry, one
++ day I'll have enough knowledge to read the documentation in a way you
++ do, because I can't see that! And .* doesn't match zero or more
++ characters? Aaanyway, I might have to get 'mastering regular
++ expressions' after all.
Well, yes, .* means zero or more non-newline characters. But, IMO,
.* isn't (?=(.*)).
Abigail
--
perl -wle 'print "Prime" if (0 x shift) !~ m 0^\0?$|^(\0\0+?)\1+$0'
------------------------------
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 3376
**************************************