[15639] in Perl-Users-Digest
Perl-Users Digest, Issue: 3052 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 15 14:10:37 2000
Date: Mon, 15 May 2000 11:10:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <958414215-v9-i3052@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 15 May 2000 Volume: 9 Number: 3052
Today's topics:
Re: strings and limits (Craig Berry)
Re: style sheet via perl/CGI Script <jeff@vpservices.com>
Summary: Accidental Creation of Static Variable nobull@mail.com
using array to assign hash mgray@wallacefloyd.com
Re: using array to assign hash (Tad McClellan)
Re: using array to assign hash <lr@hpl.hp.com>
Re: What's this line which Perl added to AUTOEXEC.BAT? <jeff@vpservices.com>
Re: What's this line which Perl added to AUTOEXEC.BAT? <gellyfish@gellyfish.com>
Re: What's this line which Perl added to AUTOEXEC.BAT? <chrisnet01@yahoo.com>
Re: Why does Perl do this? (Abigail)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 15 May 2000 17:00:29 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: strings and limits
Message-Id: <si0b9dl1rj0142@corp.supernews.com>
Ganix (ganix#gmx.net) wrote:
: Silly question, but is there a common way of
: getting - say 10 characters long - parts out of
: a string and put them into an array?
: I suppose perl can triuph with some certain
: command for this purpose.
: I think at some kind of split with regular expression.
Several ways. Probably the simplest to express (though also probably not
the most efficient) would be:
@pieces = $string =~ m/(.{1,10})/gs;
The last array element may have less than 10 characters if $string's
length isn't a multiple of 10.
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "The road of Excess leads to the Palace
of Wisdom" - William Blake
------------------------------
Date: Mon, 15 May 2000 09:22:00 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: style sheet via perl/CGI Script
Message-Id: <39202428.530D7C00@vpservices.com>
Michael Mayerhofer wrote:
>
> > print qq%<link rel=stylesheet type="text/css" href="/css/tivweb.css">\n%;
> >
> I haven't found an explanation about the use of qq and the use of % string %?!
qq() is documented in perlop under "quote and quote-like operators"
> Should qq be like the double qota (") and q like the literal (')?
Yes.
> % Seems to be a string limiter, isn't it?
Yes, with most quote-like operators you can make the delimiter anything
you want.
> Why doesnt work the same line with " "?
Because the line it is enclosing contains double quotes. The main
reason to use alternater delimiters is so that you can use double quotes
(or some other delimiter) within the delimiters without escaping them.
--
Jeff
------------------------------
Date: 15 May 2000 18:27:52 +0100
From: nobull@mail.com
Subject: Summary: Accidental Creation of Static Variable
Message-Id: <u9bt27910n.fsf_-_@wcl-l.bham.ac.uk>
Summary of the discussion so far:
Basically the debate going on is about the actual behaviour of "my $x
=1 if $y" and the perlsub manpage.
The actual behaviour is to create a varaible that is lexically scoped
but that is static (i.e. retains/shares it's value between different
invocations of the block).
The behaviour that I and (some other contibutors to this thread) find
intuative is that it should be semantically equivalent to "my $x; $x=1
if $y" or that it should be illegal.
Abigail asserts that the documentation unambigously defines the actual
behaviour as correct.
I asked Abigail to show anything in the documentation which would
categorically contadict my expectation. She cannot. Instead she
(again) showed how her intuition can lead from the documentation to
the actual behaviour. Then she asserts that she has not used
intuition and hence concludes that her interpretation of the
documentation is the only possible interpretation. If her
interpretation of the documentation is the only interpretation then
clearly any alternative must contarvene the documentation (QED!).
I do not accept the assertion that she has not used intuition.
Despite a long digression on the nature of intuition I have been
unable to convince Abigail that she is applying intuition.
So we are at an impasse.
Meanwhile, the docuementation states:
> ++ > ++ variables declared with C<my> are totally hidden from the outside
> ++ > ++ world, including any called subroutines. This is true if it's the
> ++ > ++ same subroutine called from itself or elsewhere--every call gets
> ++ > ++ its own copy.
I assert that the actual behaviour contarvenes this.
Abigail does not accept my assertion.
Abigail asked me to show how the the actual behaviour contarvenes the
first sentence taken alone. I cannot (because it does not).
I consider it so obvious that that "every call gets its own copy" is
contravened by the actual behaviour (somtimes calls share the same
copy) that I can't see any way to express it in simpler terms.
So once again we are at an impasse.
Neither of us is going to budge so I think we should leave it at that
lest we start sounding like Godzilla.
Maybe I'll submit a documentation patch.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 15 May 2000 15:12:14 GMT
From: mgray@wallacefloyd.com
Subject: using array to assign hash
Message-Id: <8fp43u$bki$1@nnrp1.deja.com>
Why cant I use the values of the array @fieldlist as the keys of the
hash %formatinfo with all the data set to xnull.
Why wont this work?
Mike Gray
mgray@wallacefloyd.com
#!/usr/bin/perl
@fieldlist = (mailing_list,
name,
org,
title,
phone,
fax,
email,
find_us,
arch,
larch,
plan,
ud,
trans,
edu,
los,
urev,
other
);
%infoformat = ();
foreach $field (@fieldlist) {
$infoformat{$field} => xnull, # i have ended this string
with ; , and nothing
}
print %infoformat;
while (($field, $data) = each (%infoformat)) {
print "$field: $data\n"
}
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 15 May 2000 11:09:51 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: using array to assign hash
Message-Id: <slrn8i04pv.vvf.tadmc@magna.metronet.com>
On Mon, 15 May 2000 15:12:14 GMT, mgray@wallacefloyd.com <mgray@wallacefloyd.com> wrote:
>Why cant I use the values of the array @fieldlist as the keys of the
>hash %formatinfo with all the data set to xnull.
>
>Why wont this work?
ask perl to tell you why, don't ask us!
>
>#!/usr/bin/perl
#!/usr/bin/perl -w
^^
^^ ask perl to help you find common mistakes
>@fieldlist = (mailing_list,
[snip a bunch of barewords. Don't use barewords. Put quotes
around your strings.
]
>%infoformat = ();
>foreach $field (@fieldlist) {
>
> $infoformat{$field} => xnull, # i have ended this string
^^ ^
^^ ^ should be semicolon
^^
^^ should be equals sign
should not use bareword. Quote your strings:
$infoformat{$field} = 'xnull';
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 15 May 2000 10:40:40 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: using array to assign hash
Message-Id: <MPG.1389d6779e4bd2f298aa80@nntp.hpl.hp.com>
In article <8fp43u$bki$1@nnrp1.deja.com> on Mon, 15 May 2000 15:12:14
GMT, mgray@wallacefloyd.com <mgray@wallacefloyd.com> says...
> Why cant I use the values of the array @fieldlist as the keys of the
> hash %formatinfo with all the data set to xnull.
...
> %infoformat = ();
> foreach $field (@fieldlist) {
>
> $infoformat{$field} => xnull, # i have ended this string
> with ; , and nothing
> }
Tad McClellan already showed how to fix this loop. The loop can also be
made implicit, with performance advantages, by using a hash slice. See
Uri Guttman's tutorial at <URL:http://www.sysarch.com/>.
@infoformat{@fieldlist} = ('xnull') x @fieldlist;
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 15 May 2000 09:27:57 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: What's this line which Perl added to AUTOEXEC.BAT?
Message-Id: <3920258D.7C9BB504@vpservices.com>
bjanko wrote:
>
> In article <pwQT4.1291$Kc1.185807@news.dircon.co.uk>, Jonathan
> Stowe <gellyfish@gellyfish.com> wrote:
> >On Sat, 13 May 2000 07:00:34 -0700, bjanko Wrote:
> >> After installing Perl from activestate.com on my Windows 98
> >> platform, the following line was written into my AUTOEXEC.BAT:
> >>
> >> SET PATH=C:\Perl\bin\
> >>
> >> This seemed to make my computer unbootable.
> >
> >I very much doubt it.
>
> Golly gee, I was sittin' right here and it booted fine before
> installing Perl, but afterward it didn't boot.
That may be, but that one line in the autoexec was not the problem.
Even if that line was related to the problem, we would have to see more
context and the asnwer would have to do with how windows computers
operate and how their autoexec.bat files function, not with Perl.
> >If you are uncertain you
> >ought to ask in some windows group as this isnt really a Perl
> >question.
>
> I did. But it's funny -- there are so few people in the Windows
> group who have installed Perl (scratching my head); yet, there
> are many more Perl group people who have installed Perl on
> Windows. It seems like more of a Perl question to me.
You may have some issue with your Perl installation that is causing the
problem and that question probably belongs here, but the question you
asked is not a Perl question is not related to whether a computer is
bootable or not.
> I appreciate your trying to help, but no one needs your snide
> attitude or condescending attitude.
Jonathan's answer was full of information. It was correct and factual.
If you truly do not know the purpose of setting the PATH in a startup
file, then you truly need to go back to basics. That is not snide, but
factual.
--
Jeff
------------------------------
Date: Mon, 15 May 2000 16:28:36 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: What's this line which Perl added to AUTOEXEC.BAT?
Message-Id: <UAVT4.1349$Kc1.188047@news.dircon.co.uk>
On Mon, 15 May 2000 04:25:33 -0700, bjanko Wrote:
> In article <pwQT4.1291$Kc1.185807@news.dircon.co.uk>, Jonathan
> Stowe <gellyfish@gellyfish.com> wrote:
>>On Sat, 13 May 2000 07:00:34 -0700, bjanko Wrote:
>>> After installing Perl from activestate.com on my Windows 98
>>> platform, the following line was written into my AUTOEXEC.BAT:
>>>
>>> SET PATH=C:\Perl\bin\
>>>
>>> This seemed to make my computer unbootable.
>>
>>I very much doubt it.
>
>
> Golly gee, I was sittin' right here and it booted fine before
> installing Perl, but afterward it didn't boot. I edited the
> line out of the autoexec.bat and it booted again. I put the
> line back and it would not boot again. But since you say YOU
> doubt it, I suppose I'll believe you and I guess it just never
> really happened!
>
> Does anyone know
>>> the purpose of the line?
>>
>>Yes. Anyone who has used a computer for more than five minutes.
>
> Oh, you're new? So that's why you didn't realize it would make
> the computer unbootable.
>
>
>>If you are uncertain you
>>ought to ask in some windows group as this isnt really a Perl
>>question.
>
> I did. But it's funny -- there are so few people in the Windows
> group who have installed Perl (scratching my head); yet, there
> are many more Perl group people who have installed Perl on
> Windows. It seems like more of a Perl question to me.
>
> I appreciate your trying to help, but no one needs your snide
> attitude or condescending attitude. Condescending, by the way,
> is when you look down your nose at others.
Thats fine I wont bother next time.
*plonk*
/J\
------------------------------
Date: Mon, 15 May 2000 18:46:55 +0100
From: "Chris" <chrisnet01@yahoo.com>
Subject: Re: What's this line which Perl added to AUTOEXEC.BAT?
Message-Id: <8fpcto$9tj$1@dvorak.ednet.co.uk>
The addition of some code to your path is not, in itself, very dangerous. It
seems odd however that there was only the code you entered and no reference
to the (already existing) path construct (the %PATH% stuff Jonathan Stowe
was commenting on).
Many applications add their executable directories, which is what the Perl
installer would have been doing, so that the system will know where to
"find" files it needs to run programs.
Perhaps the problem was that the path addition you discovered has
overwritten a directory which the system needs to work. I can only state
that I have been lucky and after hundreds of installs of ActivePerl over a
period of time it has never bitten me like this. That is a shame since I
would like to think it has not scared you off trying to do stuff with Perl
ever again.
Chris
"bjanko" <waldo700NOwaSPAM@aol.com.invalid> wrote in message
news:0f7344e3.b98bda9c@usw-ex0102-084.remarq.com...
> In article <pwQT4.1291$Kc1.185807@news.dircon.co.uk>, Jonathan
> Stowe <gellyfish@gellyfish.com> wrote:
> >On Sat, 13 May 2000 07:00:34 -0700, bjanko Wrote:
> >> After installing Perl from activestate.com on my Windows 98
> >> platform, the following line was written into my AUTOEXEC.BAT:
> >>
> >> SET PATH=C:\Perl\bin\
> >>
> >> This seemed to make my computer unbootable.
> >
> >I very much doubt it.
>
>
> Golly gee, I was sittin' right here and it booted fine before
> installing Perl, but afterward it didn't boot. I edited the
> line out of the autoexec.bat and it booted again. I put the
> line back and it would not boot again. But since you say YOU
> doubt it, I suppose I'll believe you and I guess it just never
> really happened!
>
> Does anyone know
> >> the purpose of the line?
> >
> >Yes. Anyone who has used a computer for more than five minutes.
>
> Oh, you're new? So that's why you didn't realize it would make
> the computer unbootable.
>
>
> >If you are uncertain you
> >ought to ask in some windows group as this isnt really a Perl
> >question.
>
> I did. But it's funny -- there are so few people in the Windows
> group who have installed Perl (scratching my head); yet, there
> are many more Perl group people who have installed Perl on
> Windows. It seems like more of a Perl question to me.
>
> I appreciate your trying to help, but no one needs your snide
> attitude or condescending attitude. Condescending, by the way,
> is when you look down your nose at others.
>
>
> * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network
*
> The fastest and easiest way to search and participate in Usenet - Free!
>
------------------------------
Date: 15 May 2000 16:52:41 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Why does Perl do this?
Message-Id: <slrn8i0aqp.dco.abigail@ucan.foad.org>
On 15 May 2000 02:20:14 GMT, Tramm Hudson <hudson@swcp.com> wrote:
++ [posted and cc'd to cited author]
++
++ Abigail <abigail@arena-i.com> wrote other stuff, but this is all
++ that I left in place to misquote the previous discussion:
++ %^& ... There are infinitely many
++ %^& programming mistakes one can make, using no more than 50 characters.
++
++ However, since we have a finite number of characters in our language
++ (roughly 256, if we assume character == octect) the maximum
++ number of strings in this language is:
++
++ 2^(50*8)
++
++ which is a finite, bounded number. Even assuming that each of
++ those strings may have a large (finite) number of erroroneous
++ interpretations, that still leaves us (within a constant) at
++ the same order of magnitude for possible errors within a
++ finite number of characters.
++
++ Or do you have a different interpretation that I am missing?
You are assuming that the mapping "mistake" -> "faulty program" is
one-to-one. It, of course, isn't.
There are for instance in infinite amount of things you can leave out
in your program - but all those errors contribute 0 characters to your
program.
Abigail
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 3052
**************************************