[25372] in Perl-Users-Digest
Perl-Users Digest, Issue: 7617 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 7 06:05:42 2005
Date: Fri, 7 Jan 2005 03:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 7 Jan 2005 Volume: 10 Number: 7617
Today's topics:
Re: <> the Diamond Operator (Anno Siegel)
Re: another newbie stupid question (Anno Siegel)
Re: another newbie stupid question (Anno Siegel)
Re: Calling Different scripts with 1 wrapper script <zen13097@zen.co.uk>
close() or die <postmaster@castleamber.com>
Re: Dummy regex question <not@home.net>
Re: Is zero even or odd? <george@briar.demon.co.uk>
Re: Is zero even or odd? <george@briar.demon.co.uk>
Re: Is zero even or odd? <a.newmane.remove@eastcoastcz.com>
Re: Need help with Perl regex <joe@inwap.com>
Re: perl crash on sucking $socket into array <joe@inwap.com>
perl embedding test fails on z/OS dazio_r@hotmail.com
perl module to add/change existing pdf's header/footer? <mbudash@sonic.net>
Re: PHP in Perl <spamtrap@dot-app.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 31 Dec 2004 15:07:11 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: <> the Diamond Operator
Message-Id: <cr3puv$1bd$2@mamenchi.zrz.TU-Berlin.DE>
maryellen sniffen <sal.perconte@verizon.net> wrote in comp.lang.perl.misc:
> I'm new and sorry about this - but what should I be putting inside this
> "Diamond Operator"? The FileHandle? the open file ?
What would "the open file" be in a Perl program? For all intents and
purposes, the file handle *is* the open file.
Anno
------------------------------
Date: 31 Dec 2004 14:25:41 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: another newbie stupid question
Message-Id: <cr3nh5$4m$1@mamenchi.zrz.TU-Berlin.DE>
maryellen sniffen <sal.perconte@verizon.net> wrote in comp.lang.perl.misc:
> In the perldoc's, when something is double-quoted, it looks like the opening
> double quote is actually 2 backticks ( ``$string" ). Is this a programming
> convention that I would have learned had I gone to formal school for
> computer science, or am I missing something. On my screen, double quotes
> look like ths ( "$string" ).
Those are called "smart quotes" (google for some background). They are by
no means specific to Perl, or even to programming. The particular rendering
depends on what is available in your font -- some look better than others.
Anno
------------------------------
Date: 31 Dec 2004 15:03:59 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: another newbie stupid question
Message-Id: <cr3pov$1bd$1@mamenchi.zrz.TU-Berlin.DE>
Lars Eighner <eighner@io.com> wrote in comp.lang.perl.misc:
> In our last episode, <cr3nh5$4m$1@mamenchi.zrz.TU-Berlin.DE>,
> the lovely and talented Anno Siegel broadcast on
> comp.lang.perl.misc:
>
> > maryellen sniffen <sal.perconte@verizon.net> wrote in comp.lang.perl.misc:
> >> In the perldoc's, when something is double-quoted, it looks like the opening
> >> double quote is actually 2 backticks ( ``$string" ). Is this a programming
> >> convention that I would have learned had I gone to formal school for
> >> computer science, or am I missing something. On my screen, double quotes
> >> look like ths ( "$string" ).
>
> > Those are called "smart quotes" (google for some background). They are by
> > no means specific to Perl, or even to programming. The particular rendering
> > depends on what is available in your font -- some look better than others.
>
>
> However, plain old single backticks on both sides `something`
> *do* mean something special (namely, execute the system command
> something and put the output here), so beware.
True in Perl code, but not in POD, where these are coming from.
Anno
------------------------------
Date: 31 Dec 2004 22:38:54 GMT
From: Dave Weaver <zen13097@zen.co.uk>
Subject: Re: Calling Different scripts with 1 wrapper script
Message-Id: <41d5d4fe$0$21334$db0fefd9@news.zen.co.uk>
On Fri, 31 Dec 2004 13:30:17 GMT, Paul Lalli <mritty@gmail.com> wrote:
>
> if ($0 =~ /script1$/) {
> #do something with script1.pl
> } elsif ($0 =~ /script2$/) {
> #do something with script2.pl
> } #etc
IMHO this would be better written as:
if ( $0 eq 'script1' ) {
... etc ...
> Or, if the names of your links really are the names you listed, use a
> regexp to determine which one:
> if ($0 =~ /script(\d+)$/){
> $filename = script$1.pl;
^ ^
" "
I think you forgot something...
------------------------------
Date: 31 Dec 2004 16:54:18 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: close() or die
Message-Id: <Xns95D06EEEAD4A4castleamber@130.133.1.4>
Recently a customer reported that a Perl script I had written suddenly
reported an error.
It turned out that it failed on the close (it died and reported that the
close failed after writing to the file).
It turned out that his disk quota had exceeded. So it seems that the close
flushed the buffer, which failed, and my script nicely reported this.
Bottomline: check your close. Without this it would have not been obvious.
Even if I use auto-vivication, I close explicitly.
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Fri, 07 Jan 2005 07:48:22 GMT
From: "JayEs" <not@home.net>
Subject: Re: Dummy regex question
Message-Id: <a9rDd.12024$wi2.5482@newssvr11.news.prodigy.com>
"Scott Bryce" wrote
> So don't get defensive. Learn from the mistake.
Defensive? Little bit! Lucklily not offended, takes MUCH more :-)
> You are missing the point. The reason that the first few responses did not
> solve your problem was that you did not know what the problem actually
> was. Therefore your problem description was not accurate.
I liken this to asking how to turn on the light. Say, the main question is:
I have a room and it has an overhead fixture. How do I turn it on? That is a
very accurate question, with enough information to provide an answer. That
answer clearly should be: Find the switch and flip it.
Now even though this solution works for most, and is an adequate answer to
the above question, the originator of the question might not be able to get
this to work. The problem could be that the bulb is burnt out.
You have to take it one step at a time. If you don't know to flip the switch
then how can you know that the bulb is broke? Of course you could say that
you can shake the bulb and listen, even if you don't know to flip the
switch. But if the person asking to turn on the light doesn't even know how
to flip a switch then what is the likelyhood of this same person knowing to
shake the bulb? My point is that a question can lead to another question. In
this case, the person asked to be helped with switching on the light (How do
I split a string on a space -- accurate) and then comes back and says: That
didn't work, can you check the bulb for me?(here is the script see if you
can make it work -- code sample and all)
The person asking is new at the subject matter, its probably all the
information he knows to give...
If the person asking the question was so opposed to learning, he could have
foregone asking and light a candle, which might not have been as effective,
but he probably knows how to do and gets the job done in the end.
------------------------------
Date: Fri, 31 Dec 2004 09:43:12 -0000
From: "George Dishman" <george@briar.demon.co.uk>
Subject: Re: Is zero even or odd?
Message-Id: <cr36td$rrq$1@news.freedom2surf.net>
"Nicholas O. Lindan" <see@sig.com> wrote in message
news:S3%Ad.3664$JC2.2491@newsread2.news.atl.earthlink.net...
> "George Dishman" <george@briar.demon.co.uk> wrote
>> "Nicholas O. Lindan" <see@sig.com> wrote in message
>
>
>> > What are the problems that can be solved by the
>> > conventional but not by the proposed? I'm not trying
>> > to be belligerent; I am honestly curious.
>>
>> Let's take a trivial example, you say above
>>
>> k * 0 <> 0
>>
>> If I connect k resistors of equal value in series,
>> the voltage across the chain will be k times the
>> voltage across each. If the resistors are 1 ohm
>> and I pass 1 amp through the chain then each
>> resistor will have 1 volt across it and the total
>> will be k volts. If I reduce the current to zero,
>> the voltage across any one resistor will be zero
>> but, according to your proposal, the total voltage
>> isn't zero. What is it?
>
> Executive summary: I know there are k resistors, so: V = k * 0
> The voltmeter doesn't know this: V = 0
I am an engineer. I have designed a circuit in
which there are resistors in series but I haven't
built it yet. Before the company will spend the
money to do that, I have to justify my design to
a peer review team. To do that I may have to predict
the value of V given the above conditions. I know
that it will be 0 and your math needs to predict
that.
> The goal of this lunacy is to not loose information
> if a 0 or an oo gets stuck in the works. Conventionally
> a 0 will cancel anything it is multiplied by and information
> is lost.
>
> Saying the reading is k * 0 carries _a priori_ information
> through to the final answer.
>
> As an example. Joe and I are electricians. At the shift
> change I tell Joe that the present measurement is I = 0, V = 0.
> After I have left Joe needs to extrapolate what happens
> at 1 amp and he can't.
>
> If I tell Joe that the current reading is 0 amps
> and 33*0 volts, then Joe can predict the voltage
> at 1 amp.
Joe cannot predict it because you didn't tell him
what current you used.
> I know it is 33 because I measured at
> 1 amp and got 33 volts.
Then you can tell him the resistance is 33 ohms
but at present the voltage is 0 Volts since the
current is 0 Amps.
> My former knowledge is
> not thrown away just because of the result of the
> recent measurement.
Regardless, you cannot change the rules of maths
on a whim and since you can talk of resistance in
this example, there is no need.
> This, almost bookkeeping, of 0's and oo's appears to defeat
> the normal proofs that 1/0 is meaningless.
The fact remains that if you pass 0 Amps through
a resistor, you get 0 Volts. Knowing those does
not allow you to calculate the value of the
resistor since 0/0 does not give a unique result.
1/0 is a different problem.
> Now, does the _concept_ of k * 0 <> 0 have non-zero value?
> Or is it just too odd?
Mathematically, the value isn't something you can
just pick, it has to be derived. Pragmatically it is
unworkable. Your sig says you are an engineer and
mentions electronics so I assume you know of PSpice.
How would you adjust the code to take account of this
change, set the voltage to "undefined" whenever you
have to multiply a zero and propagate that through
the design like a logic "X" in a digital simulator?
Think about how that would affect a speadsheet
program, or if it was applied to the FPU in your
processor:
k * 0 => NaN
George
------------------------------
Date: Fri, 31 Dec 2004 12:36:59 -0000
From: "George Dishman" <george@briar.demon.co.uk>
Subject: Re: Is zero even or odd?
Message-Id: <cr3h38$uok$1@news.freedom2surf.net>
"Michael Mendelsohn" <invalid@msgid.michael.mendelsohn.de> wrote in message
news:41D53D2A.A82927E6@msgid.michael.mendelsohn.de...
> George Dishman schrieb:
>> "Nicholas O. Lindan" <see@sig.com> wrote in message
>> > Saying the reading is k * 0 carries _a priori_ information
>> > through to the final answer.
>> >
>> > As an example. Joe and I are electricians. At the shift
>> > change I tell Joe that the present measurement is I = 0, V = 0.
>> > After I have left Joe needs to extrapolate what happens
>> > at 1 amp and he can't.
>> >
>> > If I tell Joe that the current reading is 0 amps
>> > and 33*0 volts, then Joe can predict the voltage
>> > at 1 amp.
>>
>> Joe cannot predict it because you didn't tell him
>> what current you used.
>
> Yes, he can.
>
> A mathematician would've written the information that Nick told Joe as
> current = 0
> voltage = 33 * current
If he wrote that, there wouldn't be a problem but
that is the same as my version that you snipped:
> > Then you can tell him the resistance is 33 ohms
> The latter formula yields a voltage for any current.
>
> For Joe to correctly deduce this from Nick's information, he just has to
> be familiar with Nick's idiosyncrasies.
>
>> Regardless, you cannot change the rules of maths
>> on a whim and since you can talk of resistance in
>> this example, there is no need.
>
> He is changing the way he writes down mathematical facts to put him
> outside the mainstream, which means people will misunderstand him,
He is going beyond that when he writes
k * 0 <> 0
if by that he means that the product of a finite
number and zero is _not_equal_to_ zero.
> resulting in arguments whenever this occurs. This is the reason why most
> people keep to standards when writing things down - to things with
> well-accepted meanings.
Agreed. the above equation doesn't mean what is
seems to say, it could mean anything at all.
George
------------------------------
Date: Fri, 31 Dec 2004 09:05:26 -0800
From: "Alfred Z. Newmane" <a.newmane.remove@eastcoastcz.com>
Subject: Re: Is zero even or odd?
Message-Id: <33lf6pF42gammU1@individual.net>
Nicholas O. Lindan wrote:
> "David Kastrup" <dak@gnu.org> wrote
>
>> So 0 is not a number?
>
> Not in the normal sense of 1, 2, 3 ... pi ....
It's a number, but dividing anything by it, including itse;f, is, lets
say it together now, ............................ drum
roll.....................
U N D F I N E D !
We now return to our regularly scheduled pointless debate...
------------------------------
Date: Fri, 07 Jan 2005 01:58:07 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Need help with Perl regex
Message-Id: <IPCdnZvEG96swEPcRVn-ug@comcast.com>
surfking wrote:
> I found this line of code
> which was parsing the /etc/termcap file located on a UNIX system.
>
> if (/(^|\|)${term}[:\|]/) {
>
> format of entries in the /etc/termcap file, I don't see how this pattern
> is successfull. Can anyone out there give me some ideas on this ?
It's designed to match entries like this:
ibmpcx|xenix|ibmx|IBM PC xenix console display:
For $term = 'ibmpcx', /^$term[|]/ matches.
For $term = 'xenix', /\|$term[|]/ matches. Same for 'ibmx'.
For $term = 'IBM PC xenix console display', /\|$term[:]/ matches.
For entries that have no aliases, /^$term[:]/ matches.
-Joe
------------------------------
Date: Fri, 07 Jan 2005 02:47:28 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: perl crash on sucking $socket into array
Message-Id: <K56dnSA9_ORf9UPcRVn-uA@comcast.com>
imahacker@the-pentagon.com wrote:
> I have isolated the problem to the @line=<$ocket> line.
That line should not be used. For interactive servers like SMTP,
you should read one line from the socket for each line you send.
You should not send the next line until you have verified that
the server did not present you with an error code.
Net::SMTP does that.
-Joe
------------------------------
Date: 6 Jan 2005 21:53:26 -0800
From: dazio_r@hotmail.com
Subject: perl embedding test fails on z/OS
Message-Id: <1105077206.735601.147670@f14g2000cwb.googlegroups.com>
I have configured perl-5.8.6 on a z/OS box (v1 R4) using 'sh Configure
-Dmake=gmake -de' and then did 'gmake'.
Then I ran './perl lib/ExtUtils/t/Embed.t' but I get this message :
------------------------------------------------------------------
# embed_test = ./embed_test
ok 2
ok 3
CEE3204S The system detected a protection exception (System Completion
Code=0C4)
.
>From entry point S_init_postdump_symbols at compile unit
offset +000003
D8 at entry offset +000003D8 at address
2010D878.
not ok 9 # system returned 11
------------------------------------------------------------------
The error comes due to the following piece of code in Embed.t :
------------------------------------------------------------------
perl_parse(my_perl, NULL, (sizeof(cmds)/sizeof(char *))-1, cmds, env);
------------------------------------------------------------------
c89 is the compiler used. Any thoughts on why the protection exception
is being generated.
Thanks in advance,
Rajarshi.
------------------------------
Date: Fri, 31 Dec 2004 18:13:34 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: perl module to add/change existing pdf's header/footer?
Message-Id: <mbudash-D4865A.10133331122004@typhoon.sonic.net>
is there a perl module to add/change an existing pdf's header/footer?
i've looked on cpan at the hundred or so modules dealing with pdfs, but
none seem to do the job.
anybody?
--
Michael Budash
------------------------------
Date: Fri, 07 Jan 2005 00:21:33 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: PHP in Perl
Message-Id: <iOSdncQoTrrDgUPcRVn-1Q@adelphia.com>
Dave F wrote:
> So I came to my senses and decided to re-code the Perl process in PHP.
You haven't *really* come to your senses yet. When you do, you'll
realize that you still have to use the same technique, regardless of the
language you choose. The script that produces the HTML just does that,
nothing else. If you want to produce an image dynamically as well as
HTML, your only option is to print an <img ...> element whose src
attribute points to a script that will produce the image data. That
script produces image data, nothing else.
It's *not* the server that connects the two requests, it's the browser.
The browser receives the HTML and parses it. That's one request. Then
upon finding an <img ...> element the browser makes another, entirely
separate request to the URL specified by the src attribute.
HTTP is entirely stateless; as far as the server is concerned, there is
no connection whatsoever between the two requests. They don't even have
to be served by the same machine - that's how separate they are.
That's the concept that's important here - and you're missing it. This
business of trying to conflate it all together into one chain of scripts
that produces both HTML and image data in a single request - that's just
daft. It won't work in any language, be it PHP, Perl, Java, or BrainF**k.
Start simple and build it up. Try it with a plain HTML page first. In
that page, place an <img ...> whose src points to a .php script. Write
that script to do something really simple, like draw a red circle.
Now, take the HTML from that page, and produce the *same* HTML, and
*only* the HTML, from a Perl or PHP script. It doesn't have to be very
dynamic at this point. It's enough to just wrap the whole page in a big
print statement to verify that the concept works.
At any rate, this is getting into the area of language-neutral CGI
discussion, so it belongs in a CGI group, not a Perl group. Followups
have been set to comp.infosystems.www.authoring.cgi.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7617
***************************************