[11865] in Perl-Users-Digest
Perl-Users Digest, Issue: 5465 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 23 14:07:55 1999
Date: Fri, 23 Apr 99 11:00:23 -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 Fri, 23 Apr 1999 Volume: 8 Number: 5465
Today's topics:
Re: .JPG version of GD? (Daniel Beckham)
Calling other perl scripts <gala@sonic.net>
Re: Calling other perl scripts <tchrist@mox.perl.com>
Re: Changing multiple lines in a file <cassell@mail.cor.epa.gov>
Re: Changing multiple lines in a file <cassell@mail.cor.epa.gov>
Re: Changing multiple lines in a file (Larry Rosler)
Re: cheap perl scripts (Daniel Beckham)
Re: combining multiple grep statements into one... (Larry Rosler)
h2ph Solaris and isa_defs <jking2019@my-dejanews.com>
Re: Help understanding this script jhelgesen@my-dejanews.com
Re: Help understanding this script <cassell@mail.cor.epa.gov>
Re: Help! Error message when using C-comment stripper f (James R. Goodfriend)
Re: Help! Error message when using C-comment stripper f (Larry Rosler)
Help: Regex Parser Testing? <scott@waddells.net>
Re: How to make an array name to be a variable? <cassell@mail.cor.epa.gov>
Re: How to receive a mail with Perl? <tchrist@mox.perl.com>
Re: I need help!!!!! jhelgesen@my-dejanews.com
Re: Is there a shorter way? (Matthew Bafford)
Re: need CGI programmers???? <cassell@mail.cor.epa.gov>
Newbie Question: While versus Until (Scratch That) (stephen)
Newbie Question: While versus Until (stephen)
Re: Newbie Question: While versus Until (Larry Rosler)
Re: Newbie Question: While versus Until <emschwar@rmi.net>
Re: Newbie Question: While versus Until <thelma@alpha2.csd.uwm.edu>
Re: newbie with a "howto" question <emschwar@rmi.net>
Re: newbie with a "howto" question <cassell@mail.cor.epa.gov>
Re: newbie with a "howto" question <aqumsieh@matrox.com>
Re: NN? ['Nother Newbie Question] <cassell@mail.cor.epa.gov>
Re: Reading in password from <STDIN> <t-armbruster@ti.com>
Reference->glob? (Andrew Allen)
Re: regex: I see THAT it works, but I don't see WHY <dgris@moiraine.dimensional.com>
Re: removing rows from table (html tags) jhelgesen@my-dejanews.com
Re: The question about debug and design <carfield@polyu.hknet.com>
Re: To trim right blanks from a field. <cassell@mail.cor.epa.gov>
Re: Unix files in MacPerl (Chris Nandor)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 23 Apr 1999 13:47:04 -0500
From: danbeck@scott.net (Daniel Beckham)
Subject: Re: .JPG version of GD?
Message-Id: <MPG.118a7c255d605d4a9896bd@news.idt.net>
In article <371F4355.5ED7@me.org>, dont.spam@me.org says...
> We have a web site where people upload photographs and we want to
> automate creation of thumbnails and watermarks. I have found lots of
> stuff for X-Windows, but no help with NT ...
That should be a subtle hint...
Daniel
------------------------------
Date: Fri, 23 Apr 1999 09:37:50 -0700
From: "Gala Grant" <gala@sonic.net>
Subject: Calling other perl scripts
Message-Id: <7fq7gs$eng$1@ultra.sonic.net>
I need to know how to call another perl script from within a script. I know
about "use" with modules, but it didn't seem like that would be the right
thing to use. I want to be able to execute the entire script while inside
the other.
Thanks,
Gala Grant
gala@sonic.net
------------------------------
Date: 23 Apr 1999 11:02:20 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Calling other perl scripts
Message-Id: <3720a79c@cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, "Gala Grant" <gala@sonic.net> writes:
:I need to know how to call another perl script from within a script.
Perl has no knowledge of "other perl scripts". You simply call
another program just as you call *any*other*program*! You use
backticks, system, a piping open, or manual fork and dup and exec.
See the innumerable examples in perlfunc, the FAQs,
and the rest of the standard docs and exmaples included
with every distribution of Perl.
--tom
--
"I discount everything Djikstra has to say because he doesn't actually
run his programs" --Rob Pike, On Djikstra's belief that bugs in your
program are a moral failure to prove your program mathematically correct.
------------------------------
Date: Fri, 23 Apr 1999 10:19:11 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Changing multiple lines in a file
Message-Id: <3720AB8F.23161AC4@mail.cor.epa.gov>
John Wilkinson wrote:
>
> Hi all,
> I am a newie to this perl stuff, so excuse my ignorance.
We're all new to something some time. Welcome to the club.
And thank you for *not* putting the word `newbie' in all caps
in your subject line. :-)
> I have a file that will need to have several lines of text changed.
> I have saved the changes in a seperate file as
> s/old text/new text/
> as I have done in the past when I wrote this as a SED script.
But this is Perl. You may want to:
[1] place these in the program instead;
[2] re-write them more concisely & efficiently using regex
features not available in sed
and/or
[3] re-think the flow of your old program, given the new constructs
you have available.
But take your time. Perl has a shallow learning curve, but it is
a *long* learning curve.
> I was under the impression that I could use this file and, after reading
> in the file to change, operate on it with this other file somehow.
> But I cant figure out how.
do 'filename.pl';
Use `perldoc perlfunc' to read about `do'.
A worse way to do this would be to say:
eval `cat filename.pl`;
which is less efficient, messier, and doesn't have the nice
feature of checking all your directories in your @INC array so you could
store subroutines this way.
When you work up to library modules, be sure to switch to `use'
and `require'.
> I am sure there must be a better way in perl, could someone help me
> please.
There are lots of ways. Of course. And for a little fun,
try the s2p program which came with your install: it converts
sed scripts to [admittedly sed-ish] Perl programs.
> Thanks,
You're welcome,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Fri, 23 Apr 1999 10:21:55 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Changing multiple lines in a file
Message-Id: <3720AC33.68B33B78@mail.cor.epa.gov>
Alexandre E. Knorst wrote:
>
> with vi
> :%s/old text/new text/g
Pardon me, but that seems like a rather un-helpful suggestion.
What does vi have to do with the poster's [legitimate] question?
If you have decided to make Abigail your model for replies, please
be sure to study Abigail's style and make any replies properly
witty and Perl-related.
TIA,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Fri, 23 Apr 1999 10:19:52 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Changing multiple lines in a file
Message-Id: <MPG.118a4b92878e8980989922@nntp.hpl.hp.com>
In article <7fpq13$l5u$2@srv4-poa.nutecnet.com.br> on Fri, 23 Apr 1999
08:10:32 -0300, Alexandre E. Knorst <mylist@zaz.com.br> says...
> John Wilkinson escreveu na mensagem
> <3720205F.B23F8F6B@soton.sc.philips.com>...
> >I am a newie to this perl stuff, so excuse my ignorance.
> >I have a file that will need to have several lines of text changed.
> >I have saved the changes in a seperate file as
> >I have done in the past when I wrote this as a SED script.
> >I was under the impression that I could use this file and, after reading
> >in the file to change, operate on it with this other file somehow.
> >But I cant figure out how.
> >
> >I am sure there must be a better way in perl, could someone help me
> >please.
>
> with vi
> :%s/old text/new text/g
That seems not to answer the question about how to do it using Perl.
The documentation of the functions do(), require(), and use() would be
much more informative.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 23 Apr 1999 13:46:04 -0500
From: danbeck@scott.net (Daniel Beckham)
Subject: Re: cheap perl scripts
Message-Id: <MPG.118a7be2ae5413d29896bc@news.idt.net>
Hey, hey! Homework? I'll be glad to do the work for you... although, I
would probably charge a medium amount of money.
Contact me at danbeck@scott.net
Daniel
In article <372f40c2.3349313@nntp.best.com>, pejman@pejman.com says...
> Hi,
>
> I am looking for somebody, who can write me some small perl scripts
> for small amount of money. Please let me know if you are interested
> or if you know somebody who is willing to do that.
>
> (please reply to my email-address)
>
> Thanks in advance,
> Pejman
>
>
>
------------------------------
Date: Fri, 23 Apr 1999 10:14:51 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: combining multiple grep statements into one...
Message-Id: <MPG.118a4a6af6b773ef989921@nntp.hpl.hp.com>
In article <slrn7hsb04.mh3.drbrain@josefine.ben.tuwien.ac.at> on 21 Apr
1999 19:50:28 GMT, markus <drbrain@ziemlich.org> says...
> In article <7fl99n$8u7$1@shell18.ba.best.com>, Jim Matzdorff wrote:
> >I am wondering if there's a neat perl trick to combine multiple perl
> >grep statements into one. For instance, currently I have the following
> >lines:
>
> try:
>
> @found = grep( /(Pattern1|PAttern2)/, @data);
The request was to combine sequential greps, which means an AND
condition. This code produces an OR condition.
All of your parentheses are superfluous, by the way.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 23 Apr 1999 17:27:22 GMT
From: John <jking2019@my-dejanews.com>
Subject: h2ph Solaris and isa_defs
Message-Id: <7fqahk$7bq$1@nnrp1.dejanews.com>
I am running Perl5. on a Solaris 2.6 system and having major upgrade headaches
with it going from 4 to 5.
I would like to apply the patch info to h2ph on the system and see if this
works (cant recompile the Perl system to lates since the Perl system is part
of some other custom kit which would break other dependencies).
The problems are about the isa_defs.ph file, it just dies since it cant find
anything is defined. I figure there are more.
I tried using the 5005 h2ph on the troubled system so I could get the various
switches (-h etc that were not available on the problem box running 5002).
That allowed me to fix p4 to p5 upgrade syntax errors. Now I need a way to
get the headers moved properly.
Thanks,
--
-John
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 23 Apr 1999 16:28:27 GMT
From: jhelgesen@my-dejanews.com
Subject: Re: Help understanding this script
Message-Id: <7fq735$470$1@nnrp1.dejanews.com>
In article <7fq24o$v3r$1@nnrp1.dejanews.com>,
gustavo9000@my-dejanews.com wrote:
> Hello
>
> I need some help understanding the following lines in a HTML source code.
>
> <p><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
That's an SGML document type declaration. Most browsers consider this to be
optional. Looks like the "<p>" has been added by a post-processor of some
sort.
-- jeff
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 23 Apr 1999 10:51:06 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Help understanding this script
Message-Id: <3720B30A.BDE4F7E0@mail.cor.epa.gov>
gustavo9000@my-dejanews.com wrote:
>
> Hello
>
> I need some help understanding the following lines in a HTML source code.
>
> <p><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
> [snip]
> PS: It4s an ASP Container
I'm sorry, but you're asking in the wrong newsgroup. As you yourself
have implicitly pointed out. The question is about html code,
and possibly a relationship to ASP. So you need to ask this
question in one of the many html newsgroups.
comp.lang.perl.misc is devoted to Perl programming, and Perl
is not synonymous with web programming.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: 23 Apr 1999 16:20:49 GMT
From: GoodfriB@jntf.osd.mil (James R. Goodfriend)
Subject: Re: Help! Error message when using C-comment stripper from perlfaq
Message-Id: <7fq6l1$b13$1@news1.rmi.net>
In article <x3yiuaolfyb.fsf@tigre.matrox.com>, aqumsieh@matrox.com says...
>
>
>GoodfriB@jntf.osd.mil (James R. Goodfriend) writes:
>
>> When I run this using -w I get the following error message:
>>
>> Use of uninitialized value at (program) line 19, <CFILE> chunk 1.
>>
>> ...this shows up about 20 times. Can anyone tell me what I can do to
>> suppress this damn message? It's driving me slowly insane...
>
>I have a wacky idea. Find out what variable(s) you're trying to access
>on line 19 and is/are undefined, and fix your code.
>
>Another idea would be to turn off the monitor.
>
Well, obviously, if I knew what variables were being accessed I
wouldn't have a problem. The only variables involved are are $_ (which
shouldn't be undefined) and $2 in the second half of the s/// expression. If
the $2 is coming back undefined, I have no idea what to do about that...perl
won't let me mess with the variable outside of the s/// expression...?
-Bob
------------------------------
Date: Fri, 23 Apr 1999 10:28:42 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help! Error message when using C-comment stripper from perlfaq
Message-Id: <MPG.118a4da8be0debb989923@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7fq6l1$b13$1@news1.rmi.net> on 23 Apr 1999 16:20:49 GMT,
James R. Goodfriend <GoodfriB@jntf.osd.mil> says...
...
> Well, obviously, if I knew what variables were being accessed I
> wouldn't have a problem. The only variables involved are are $_ (which
> shouldn't be undefined) and $2 in the second half of the s/// expression. If
> the $2 is coming back undefined, I have no idea what to do about that...perl
> won't let me mess with the variable outside of the s/// expression...?
The only way you can get an undefined error from $2 in the substitution
part of a s/// expression is if the regex part has failed to capture two
(or more) values.
Without seeing the expression and the value of $_ you are matching
against, no one here can help you further.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 23 Apr 1999 16:24:28 GMT
From: Scott Waddell <scott@waddells.net>
Subject: Help: Regex Parser Testing?
Message-Id: <37209E9D.E5B16AA0@waddells.net>
I'm looking for a way to automate testing whether or not a particular
regular expression parser is working properly.
Can anyone point me to any tools or input/output sequences for testing
third party regex engines?
Ideally I'd like to have a series of test patterns, some test input
text, and a file containing the desired results of searching for each
test pattern on the input text. Ultimately I need to be able to confirm
whether or not a third party regex engine has correctly implemented
"Perl 5" regex matching.
Please respond via email as well as usenet - Thanks!
Scott Waddell
------------------------------
Date: Fri, 23 Apr 1999 10:55:53 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How to make an array name to be a variable?
Message-Id: <3720B429.159A590C@mail.cor.epa.gov>
Mike.Wescott@ColumbiaSC.NCR.COM wrote:
> [snip]
> What we're seeing here are people that have reached this hurdle in
> their development as programmers and are balking. They've got a
So what you're saying is that we're the jockeys who have been
thrown to the ground and trampled? :-)
So we can just pick Tom up off the turf, give him a shot of
phenbutazine from the horse's trainer, and he'll be okay in a few
days?
> problem that involves multiple instances of the same kind of data
> structures in the program simultaneously. When it's a sequential
> problem they just gave the data a name and processed it, then replaced
> that data with new data, keeping the same name. Now they've got a
> problem where they need an arbitrary number of "names" for the data
> and that's how they see the problem: managing the name of the data
> item. They haven't made the leap to thinking of aggregates as
> components of other aggregates.
Good point. And I think you're giving them more credit than
I did, as well.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: 23 Apr 1999 10:01:56 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How to receive a mail with Perl?
Message-Id: <37209974@cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
You simply create a sendmail alias or a .forward file that filters
incoming mail for a particular addressee into a perl script,
which then processes whatever arrives.
--tom
--
"Beware of all enterprises that require new clothes."
- Thoreau
------------------------------
Date: Fri, 23 Apr 1999 16:32:20 GMT
From: jhelgesen@my-dejanews.com
Subject: Re: I need help!!!!!
Message-Id: <7fq7ak$4bn$1@nnrp1.dejanews.com>
> The point is I cant launch the script show.pl with the link <a
> href=/cgi-bin/com/show.pl?index=12345>"
>
> Whats wrong with the script show.pl
It may be that your browser expects quotes around the URL.
Does show.pl operate correctly if you type that URL into your browser's
address bar?
-- jeff
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 23 Apr 1999 16:06:11 GMT
From: dragons@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Is there a shorter way?
Message-Id: <slrn7i159t.eh.dragons@dragons.duesouth.net>
On 23 Apr 1999 14:39:23 GMT, Abigail <abigail@fnx.com>
lucked upon a computer, and thus typed in the following:
: \\ On Thu, 22 Apr 1999 09:22:23 GMT, pingouino@my-dejanews.com wrote:
: \\ >So, "foo" becomes "fooxxx", "foos" becomes "foosxx", "foobar" remains
: \\ >"foobar" and "foobars" remains "foobars" (note how the 7-letter word is
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: \\ >not truncated).
^^^^^^^^^^^^^
: perl -e'print"$ENV{USER}xxxxxx"=~/(.{6})/'
% echo $USER
dragons
% perl -le'print"$ENV{USER}xxxxxx"=~/(.{6})/'
dragon
%
: Abigail
--Matthew
------------------------------
Date: Fri, 23 Apr 1999 10:28:29 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: need CGI programmers????
Message-Id: <3720ADBD.E015B333@mail.cor.epa.gov>
cindycrawford@my-dejanews.com wrote:
>
> need a CGI programmer?
> check our website at
> http://cgi-shop.com
Yep, I sure need a CGI programmer.. who doesn't know the difference
between CGI and Perl.
Wait a minute.. Cindy Crawford? CGI programmer?
Of course? Let's match her up with that guy with the 'adult'
web sites who was looking for CGI help! Talk about your perfect
match...
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Fri, 23 Apr 1999 08:25:17 -0800
From: stephen@oasis.novia.net (stephen)
Subject: Newbie Question: While versus Until (Scratch That)
Message-Id: <v91U2.269$5z.102610@WReNphoon1-bin>
I found my problem: I was using the assignment operator in place of
equality. *doh!*
@a = <STDIN>;
$b = @a;
print ("Now for the reverse order:\n");
until ($b = 0) {
^^^^^^
print $a[$b-1];
$b--;
}
It works now.
stephen B^)
**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****
------------------------------
Date: Fri, 23 Apr 1999 08:01:36 -0800
From: stephen@oasis.novia.net (stephen)
Subject: Newbie Question: While versus Until
Message-Id: <PQ0U2.266$5z.95073@WReNphoon1-bin>
I was doing an excercise in the book "Learning Perl", and I had a chance to
experiment with the
"until" statement. This is the piece I wrote:
@a = <STDIN>;
$b = @a;
print ("Now for the reverse order:\n");
until ($b = 0) {
print $a[$b-1];
$b--;
}
What I got was an infinite loop. I rewrote using a "while" statement:
@a = <STDIN>;
$b = @a;
print ("Now for the reverse order:\n");
while ($b != 0) {
print $a[$b-1];
$b--;
}
That gave me the results I wanted. While I realize I can reverse the order
of an array with the reverse
function, I wanted a chance to see how the "until" statement worked. Why
did the "until" statement in
the first piece I wrote go wrong?
**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****
------------------------------
Date: Fri, 23 Apr 1999 09:41:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Newbie Question: While versus Until
Message-Id: <MPG.118a4291bddbf812989920@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <PQ0U2.266$5z.95073@WReNphoon1-bin> on Fri, 23 Apr 1999
08:01:36 -0800, stephen <stephen@oasis.novia.net> says...
> I was doing an excercise in the book "Learning Perl", and I had a chance to
> experiment with the "until" statement. This is the piece I wrote:
>
> @a = <STDIN>;
> $b = @a;
> print ("Now for the reverse order:\n");
> until ($b = 0) {
What warning did you get about this line of code? Oh, you didn't have
warnings enabled? Then do it again, now -- and every time!
> print $a[$b-1];
> $b--;
> }
>
> What I got was an infinite loop.
I'm not surprised at all.
...
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 23 Apr 1999 11:11:57 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Newbie Question: While versus Until
Message-Id: <xkfhfq7gt2a.fsf@valdemar.col.hp.com>
stephen@oasis.novia.net (stephen) writes:
> Why did the "until" statement in the first piece I wrote go wrong?
>
> until ($b = 0) {
^
Assuming you copied and pasted your code, instead of retyping it, that's
why. I'm surprised that this doesn't report an error with '-w', but I've
got 5.004_04 here; is that fixed in 5.005?
-=Eric
------------------------------
Date: 23 Apr 1999 17:21:20 GMT
From: Thelma Lubkin <thelma@alpha2.csd.uwm.edu>
Subject: Re: Newbie Question: While versus Until
Message-Id: <7fqa6g$370$1@uwm.edu>
Larry Rosler <lr@hpl.hp.com> wrote:
: [Posted and a courtesy copy sent.]
: In article <PQ0U2.266$5z.95073@WReNphoon1-bin> on Fri, 23 Apr 1999
: 08:01:36 -0800, stephen <stephen@oasis.novia.net> says...
:> I was doing an excercise in the book "Learning Perl", and I had a chance to
:> experiment with the "until" statement. This is the piece I wrote:
:>
:> @a = <STDIN>;
:> $b = @a;
:> print ("Now for the reverse order:\n");
:> until ($b = 0) {
: What warning did you get about this line of code? Oh, you didn't have
: warnings enabled? Then do it again, now -- and every time!
I ran this under perl -c, with -w and use strict both on, and I
got a simple 'syntax ok' message with no warnings--it did of course go
into an infinite loop if I tried to execute. Strange...
but, Stephen, you've written
until ( $b = 0) instead of until($b == 0); since until
executes its body before checking whether condition is
satisfied, it will never see $b==0: it decrements before
checking and sees -1 the first time through
--thelma
:> print $a[$b-1];
:> $b--;
:> }
:>
:> What I got was an infinite loop.
: I'm not surprised at all.
: ...
: --
: (Just Another Larry) Rosler
: Hewlett-Packard Company
: http://www.hpl.hp.com/personal/Larry_Rosler/
: lr@hpl.hp.com
------------------------------
Date: 23 Apr 1999 10:07:28 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: newbie with a "howto" question
Message-Id: <xkfr9pbgw1r.fsf@valdemar.col.hp.com>
abigail@fnx.com (Abigail) writes:
> derose@my-dejanews.com (derose@my-dejanews.com) wrote on MMLX September
> MCMXCIII in <URL:news:7fnfbl$jpj$1@nnrp1.dejanews.com>:
> \\ Hello,
> \\
> \\ I'm new at Perl, and don't really have the patience's to find the
> \\ answers in my books, so I thought I would ask some experts.
>
> I'd gladly come over. $125/hour plus expenses. Minimum 3 days.
What, no (sur)charge for travel expenses? You're slipping. :^)
-=Eric
------------------------------
Date: Fri, 23 Apr 1999 09:30:18 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: newbie with a "howto" question
Message-Id: <3720A01A.F683547D@mail.cor.epa.gov>
bj wrote:
>
> > derose@my-dejanews.com writes:
> > > I'm new at Perl, and don't really have the patience's to find the answers in
> > > my books, so I thought I would ask some experts.
>
> Do only I find it fascinating that a fairly trivial question, posted
> with much attitude, gets a bunch of serious, and insightful
> answers... along with some chiding, whereas the same type of question
> posted sans attitude pretty much gets a rtfm or faq response?
Oh, that's all my fault. Look at what the *real* experts posted in this
thread today. I find that my internal state machine is remarkably
inconsistent, so some days I just skip over those posts, and other days
I actually spend a few minutes trying to educate.
And it also depends on the question itself. A Perl question is
more likely to get an answer than some html or Os question dressed up
in a llama's coat. Or a question about WebTV, or shell programming,
or ...
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Fri, 23 Apr 1999 11:11:49 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: newbie with a "howto" question
Message-Id: <x3yn1zztlqi.fsf@tigre.matrox.com>
derose@my-dejanews.com writes:
> I'm new at Perl, and don't really have the patience's to find the answers in
> my books, so I thought I would ask some experts.
You deserve to be kill-filed; and so you shall be.
------------------------------
Date: Fri, 23 Apr 1999 09:53:01 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: NN? ['Nother Newbie Question]
Message-Id: <3720A56D.9B83344F@mail.cor.epa.gov>
Mark Stegemeyer wrote:
>
> Geez, I hope this works. I'd hate to ask a stupid question *and* screw up my
> first post.
> Step 1. Check the documentation. Did this.
Good...
> Step 2. Check DejaNews. Did this.
Good...
> Step 3. Repeat Steps 2 & 3. Did this.
Very good...
> Step 4. Check relavancy of post. Did this (I think).
That's important too.
Since you didn't munge your e-mail address with mystic invocations to
ward off canned pork products, you'll receive an e-mail form gnat with
a lot of good tips. One of them is [paraphrased]:
Post some code showing the problem. Not all your code, but a
cut-down, still-complete example that illustrates what you mean.
This is really important. Most Perl is used for things other than
CGI, so you can't expect an outsider to grok your code through
remote viewing.
> PS- Anybody know if Randal Schwartz went to Gladstone High School? I went
> there with one, but it sounds so much like a bad pick-up line I'm
> embarrassed to ask him directly!
Did the Randal you knew have a middle initial L?
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Fri, 23 Apr 1999 12:40:31 -0500
From: "Tim Armbruster" <t-armbruster@ti.com>
Subject: Re: Reading in password from <STDIN>
Message-Id: <4k2U2.7$D%2.459@dfw-service1.ext.raytheon.com>
I stand corrected, and apologize.
------------------------------
Date: 23 Apr 1999 17:15:38 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Reference->glob?
Message-Id: <7fq9rq$s3f$1@fcnews.fc.hp.com>
If I have a sub reference from, say, the UNIVERSAL::can function, is
there an (easy) way to get the glob (or just the fully-qualified name)
for that sub? I know anonymous subs won't have namespace entries, but
UNIVERSAL::can shouldn't return those, right? I'm thinking of
something a little more elegant than:
$Pkg::{(grep(\&{$Pkg::{$_}} eq $sub,keys %Pkg::))[0]}
which doesn't really work for all circumstances anyways, since 'a'
might not be in my package namespace %Pkg:: but in one of my
superclass namespaces.
Hmm... the above code only gives one glob for aliased subs... so I
guess I'd have to be able to handle a list of globs.
In other words, I'm looking for the "inverse" function of *a{CODE}...
Andrew
------------------------------
Date: 23 Apr 1999 11:01:03 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: regex: I see THAT it works, but I don't see WHY
Message-Id: <m37lr3z2y8.fsf@moiraine.dimensional.com>
Uri Guttman <uri@sysarch.com> writes:
> >>>>> "DG" == Daniel Grisinger <dgris@moiraine.dimensional.com> writes:
<snip who uses ?PATTERN?>
> DG> I do.
>
> why?
Because there are things that it makes much, much, simpler.
> it is deprecated,
For some meaning of deprecated. The manpage reads-
This usage is vaguely deprecated, and may be removed
in some future version of Perl.
I can assure you, though, that if it ever does go away I'll
have a patch ready to put it back almost instantly. Losing
this would break far too much of my code for me to tolerate.
> very obscure,
It is no more obscure than the bizarre treatment of / / by
split. Both are clearly documented in the manpages.
If a perl programmer has a problem with ?PATTERN?, then that person
needs to spend some more time with the manpages before representing
himself as a perl programmer.
> and can be easily done with the
> regular m// (as the camel says, just break out of the loop).
You have no idea what you are talking about. You cannot recreate the
functionality of ?PATTERN? by simply looping over m//, not without
keeping around a huge pile of variables to maintain state.
> if i were to see m?? i might not even know what is is for a
> second.
That is your problem, not mine.
> what benefit do you get from only matching the first time it
> is used before a call to reset? show some code where it actually is
> useful.
In the snippet below %message is a tied hash with an extremely
expensive STORE method-- too expensive to call unless absolutely
necessary. <INCOMING> is returning strings that can be up to 100 MB
long, and the regexen are dynamically constructed and occasionally end
up smashing perl's regex size limits. In other words, this code
represents some seriously non-trivial computation.
while ($record = <INCOMING>) {
$message {bad_uid} = 1 if $record =~ ?$bad_uid?;
$message {bad_conn} = 1 if $record =~ ?$bad_conn?;
# in real life there are sometimes several hundred
# expressions that could be tested
}
Now, I'm already generating all of this code at runtime
and eval()ing it. That isn't too hard to keep track of
mentally and to troubleshoot when something goes wrong.
The reason it isn't too hard is that I don't have to worry
about creating, managing, and destroying a whole pile of
variables in the generated code. Have you ever tried to
debug a program that writes most of its own code at runtime?
It isn't the easiest task in the world.
Consider how this would have to be done if I didn't use ??.
while ($record = <INCOMING>) {
$message {bad_uid} = 1 if (!$seen_bad_uid &&
$record =~ /$bad_uid/ &&
$seen_bad_uid = 1);
$message {bad_conn} = 1 if (!$seen_bad_conn &&
$record =~ /$badd_conn/ &&
$seen_bad_conn = 1);
.......
}
Besides the silly extraneous state variables that have to
be carefully maintained there is also an unnecessary test
on every line of code. No, the test isn't enough of a bottleneck
to worry about normally, but in this case it is just another
problem that is introduced for no reason.
Of course, I could just try applying these huge regexes to the
incoming data over and over again and calling STORE over and over
again, but profiling indicated that that was the bottleneck in this
application. I ended up speeding the app up by more than 25% when I
switched to using ??. For a process with a normal runtime measured in
days that is quite substantial.
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Fri, 23 Apr 1999 16:26:01 GMT
From: jhelgesen@my-dejanews.com
Subject: Re: removing rows from table (html tags)
Message-Id: <7fq6uj$3uj$1@nnrp1.dejanews.com>
> # i can remove the set of TR tags likes this..
> s{<tr\b.*?</tr>}{}s;
> print $_, "________\n";
>
> # but how can i remove the last set??
How about
s{<tr[^>]*>.*?</tr>}{}s;
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 23 Apr 1999 23:20:57 +0800
From: Carfield Yim <carfield@polyu.hknet.com>
To: xidicone@iname.com
Subject: Re: The question about debug and design
Message-Id: <37208FD8.A6F5B169@polyu.hknet.com>
I know that I want to write persuade code, but how to write it well?
I find that I will always change the persuade code a lot as I haven't
consider many thing,
and the other reason is I find the original design is impossible to
implentment, or is not a good design,
so I think that there shall be some thing do before writing persuade code,
right?
And do you have any recommendation of debugging?
can we analysis the bug logically?
Jussi Jumppanen wrote:
> Carfield Yim wrote:
>
> > I am a starter of programming,
> > I find I always have no idea how to design and I always debug by "try
> > and error"
> >
> > How can I train my design
>
> Takes some time to put you thoughts down on paper before actually
> sitting
> down to code. Try to desging you code to a particular style. For example
> if
> you want use a do top down type of desging aproach then try to break you
> problem down into small functions using psuedo code and paper. As an
> very simple example:
>
> Main routine
> begin
>
> read in the records and store them somewhere (one function)
>
> process the stored records (another function)
>
> print the result produced (anaother function)
>
> end
>
> read function
> begin
> ...
>
> end
>
> If you want to use an object oriented approach then try to identify the
> objects and put these down on paper.
>
> Now take you paper and start to write some code.
>
> > and debug skill?
>
> This is just practice and understanding the machine. For example don't
> be scared to have a look at the assmebler output. This can sometimes
> help when it comes to detecting problems.
>
> Jussi Jumppanen
> Author of: Zeus for Windows, Win32 (Brief, WordStar, Emacs) Text Editor
> "The C/C++, Java, HTML, Pascal, Cobol, Fortran programmers text editor"
> Home Page: http://ourworld.compuserve.com/homepages/jussi/
------------------------------
Date: Fri, 23 Apr 1999 09:13:19 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: To trim right blanks from a field.
Message-Id: <37209C1F.D748AD0A@mail.cor.epa.gov>
Jay Glascoe wrote:
>
> [snip]
> but what does 'y' stand for? Let's try to sneak up on the problem :o)
>
> "For sed devotees, y is provided as a synonym for tr."
> --perlop
>
> "Perl is to sed as C is to assembly language."
> --Tom Christiansen
>
> So... "tr" is to "y" as ... ??
strtok is to OPSYN ?
^^ ^
Just trying to be helpful :-)
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Fri, 23 Apr 1999 13:36:07 -0400
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Unix files in MacPerl
Message-Id: <pudge-2304991336070001@192.168.0.77>
In article <u3e1r1ea0.fsf@sds.no>, hals <haakon.alstadheim@sds.no> wrote:
# Jason Holland <jason.holland@dial.pipex.com> writes:
# [snip]
# > Thanks again, looks like I'll have to put aside some of the laziness and
# > actually write a script to do it for me!
# [snip]
#
# Look at the CPAN.pm (module not site) that is used by MacPerl. Fairly
# experimental still, but I seem to remember seeing som automagic for
# converting text files after unpacking the tar.gz that it gets from
# CPAN (the sites, not the perl module).
The CPAN module on CPAN is the same one MacPerl uses, and it isn't
"experimental" per se. That's not to say it works flawlessly, and has not
bugs. But yes, it does some funky things with newlines, because the
Compress::Zlib function doesn't honor $/, but uses \n as the input record
separator, which breaks under MacPerl if the file uses LFs for newlines
(as all the files do). Then it uses some code (for now put in
ExtUtils::MM_MacOS) to convert the module files etc. after getting them
from the tar using Archive::Tar. The cpan-mac distribution (in .sit.bin
format) in $CPAN/authors/id/CNANDOR/ has all the code and information.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: 12 Dec 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 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5465
**************************************