[7033] in Perl-Users-Digest
Perl-Users Digest, Issue: 658 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 25 03:07:35 1997
Date: Wed, 25 Jun 97 00:00:36 -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 Wed, 25 Jun 1997 Volume: 8 Number: 658
Today's topics:
Re: ***How to get info from the HTML files in other ser (mark carroll)
Re: a string to an array <jhi@alpha.hut.fi>
Re: Checking a string for "@' and "." (Abigail)
Re: Checking a string for "@' and "." <rootbeer@teleport.com>
Re: Checking a string for "@' and "." <rootbeer@teleport.com>
Re: Checking a string for "@' and "." (Craig Berry)
Re: Checking a string for "@' and "." (Craig Berry)
Re: checking for blanks (Craig Berry)
Re: Delete specific element from list <rootbeer@teleport.com>
Re: Efficiency of 'my' declaration w/in loop? <rootbeer@teleport.com>
Re: forking without wait <rootbeer@teleport.com>
Re: forking without wait (Michael Fuhr)
Re: HTTPD:Authen (Magnus Bodin)
Newbie question: 500 Server Error <ip201945@ip.pt>
Re: Perl "compiler" or how do you protect your code? <rootbeer@teleport.com>
perl script on WinNT <kola@cs.put.poznan.pl>
Re: PLEASE HELP A NEWBIE!! <rootbeer@teleport.com>
Re: Q: an alternative to this use of "goto"? (Abigail)
Re: Q: an alternative to this use of "goto"? <rootbeer@teleport.com>
Re: Q: an alternative to this use of "goto"? <rootbeer@teleport.com>
Q: List/scalar context with methods (Kevin Zwack)
Re: Q: MacPerl, MacHTTP and CGI <rootbeer@teleport.com>
Re: Quick PERL Quesiton <rootbeer@teleport.com>
Re: regular expressions (Quentin Fennessy)
system call graham.staker@wmc.com.au
USA-NYC-UNIX/SYBASE/PERL CONSULTING OPPORTUNITY (Katrina Hawkins)
Re: Validating E-Mail addresses and URL's <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 23 Jun 1997 17:42:35 GMT
From: carroll@bonn.cis.ohio-state.edu (mark carroll)
Subject: Re: ***How to get info from the HTML files in other server??***
Message-Id: <5omcib$lqc$1@news.cis.ohio-state.edu>
CGI is more than enough; then people don't need a Java-enabled
browser. Just have your script grab the information from wherever and
compose a nice web page dynamically... or have a cron job do it
periodically or whatever, if that suits your needs, then you don't
need CGI at all.
Followups have been trimmed. You're posting to way too many groups.
-- Mark
------------------------------
Date: 23 Jun 1997 22:41:35 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: a string to an array
Message-Id: <oeek9jlksy8.fsf@alpha.hut.fi>
Please study the perlfunc manual page and the split function.
@array = split(//, $string);
--
$jhi++; # http://www.iki.fi/~jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: Mon, 23 Jun 1997 17:38:10 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Checking a string for "@' and "."
Message-Id: <EC8ozn.8Mr@nonexistent.com>
Mattias Lvnnqvist (mattias.lonnqvist@uidesign.se) wrote on 1392 September
1993 in <URL: news:33AE318B.2A2E@uidesign.se>:
++
++ One easy way is:
++ $_=$string_to_check;
++ if ((/@/)&&(/./) {
Easy, yes. Correct, no. /./ matches any string containing at least
one non newline character. /\./ matches a string containing a .
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=$]*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Mon, 23 Jun 1997 11:17:32 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Mattias Lvnnqvist <mattias.lonnqvist@uidesign.se>
Subject: Re: Checking a string for "@' and "."
Message-Id: <Pine.GSO.3.96.970623111245.9838Q-100000@kelly.teleport.com>
On Mon, 23 Jun 1997, Mattias L=F6nnqvist wrote:
> Dean Hollister wrote:
> > Can anyone point me to the required code to check whether or not a
> > string has BOTH the "@" and "." characters in it?
> One easy way is:
>=20
> $_=3D$string_to_check;
> if ((/@/)&&(/./) {
Whups! You have to backwhack the dot in a regular expression. (And in
general you want to backwhack the @-sign as well, but that doesn't
affect this case.) And your parens don't seem to match; I'm sure you meant
this.
if (/\@/ && /\./) { ... }
There are more efficient ways to do this, I think, but this should do for
most purposes. (Gee, I wonder whether the original poster was trying
to verify the format of an e-mail address? :-)=20
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 24 Jun 1997 20:31:27 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Craig Berry <cberry@cinenet.net>
Subject: Re: Checking a string for "@' and "."
Message-Id: <Pine.GSO.3.96.970624201448.17167C-100000@kelly.teleport.com>
On 24 Jun 1997, Craig Berry wrote:
> Tom Phoenix (rootbeer@teleport.com) wrote:
> : I would have used index, or maybe a pair of pattern matches.
> :
> : index($_, '@') > -1 and
> : index($_, '.') > -1
> :
> : /\@/ and /\./ # Find @ and . both
>
> That last one would be my choice, but Jeff Friedl has another cool
> suggestion in Mastering Regular Expressions (*read this book*) which
> lets you do the whole thing in one regex with similar efficiency:
>
> /^(?=.*?\@)(?=.*?\.)/
>
> If you want to match past newlines, just use the /s qualifier
> to make . include \n.
>
> (I seem to recall he credited this to Randal Schwartz, but don't have
> the book handy to check.)
Yep, that one was Randal's fault. :-) It should be near the same
efficiency as the paired regexps I offered. But I don't think that, in
general, it beats the use of index() for speed. It certainly doesn't win
for readability, but Randal rarely optimizes for that. :-)
Seriously, that method scores pretty low for maintainability, readability,
and ease of coding. (It scores high for coolness, though!)
It's pretty easy to mess up a regular expression like that one. For
example, you could forget the /s, or you could use plus instead of star,
or you could forget to backwhack the dot. Even omitting the anchor (caret)
has serious efficiency implications. And don't forget to backwhack the
@-sign! Still, if you _need_ the power of regular expressions, it's a good
one; in this case, it's overkill, kind of like using your rifle to shut
off the TV set, when the pliers are sitting right there.
Regular expressions are powerful, but when index can be used, it will
usually be better.
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 24 Jun 1997 22:25:44 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Checking a string for "@' and "."
Message-Id: <5ophh8$i4a$2@marina.cinenet.net>
Tom Phoenix (rootbeer@teleport.com) wrote:
: On 24 Jun 1997, ? the platypus {aka David Formosa} wrote:
: > Dean Hollister <deanh@nospam.mail> writes:
: > >Can anyone point me to the required code to check whether or not a
: > >string has BOTH the "@" and "." characters in it?
: >
: > I would use the regex /(\@.*\.)|(\..*\@)/
:
: I would have used index, or maybe a pair of pattern matches.
:
: index($_, '@') > -1 and
: index($_, '.') > -1
:
: /\@/ and /\./ # Find @ and . both
That last one would be my choice, but Jeff Friedl has another cool
suggestion in Mastering Regular Expressions (*read this book*) which lets
you do the whole thing in one regex with similar efficiency:
/^(?=.*?\@)(?=.*?\.)/
If you want to match past newlines, just use the /s qualifier to make .
include \n.
(I seem to recall he credited this to Randal Schwartz, but don't have the
book handy to check.)
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 25 Jun 1997 04:16:33 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Checking a string for "@' and "."
Message-Id: <5oq632$8ie$1@marina.cinenet.net>
Tom Phoenix (rootbeer@teleport.com) wrote:
: On 24 Jun 1997, Craig Berry wrote:
: > That last one would be my choice, but Jeff Friedl has another cool
: > suggestion in Mastering Regular Expressions (*read this book*) which
: > lets you do the whole thing in one regex with similar efficiency:
: >
: > /^(?=.*?\@)(?=.*?\.)/
: >
: > If you want to match past newlines, just use the /s qualifier
: > to make . include \n.
: >
: > (I seem to recall he credited this to Randal Schwartz, but don't have
: > the book handy to check.)
:
: Yep, that one was Randal's fault. :-) It should be near the same
: efficiency as the paired regexps I offered. But I don't think that, in
: general, it beats the use of index() for speed. It certainly doesn't win
: for readability, but Randal rarely optimizes for that. :-)
Oh, of course, in real life and when not high on regexes in the wake of
reading MRE, I'd use either paired index() calls or the paired separate
regexes. It did occur to me after posting the above that Randal's
single-regex version can be optimized a bit more, at the cost of its
lovely symmetry:
/^(?=.*?\@).*?\./
After all, there's no reason to save 'lookahead state' on the second
search (for the \.). This should squeeze a teeny bit more performance
out of the single-regex option.
: Seriously, that method scores pretty low for maintainability, readability,
: and ease of coding. (It scores high for coolness, though!)
Think of it as a classic example of optimizing for job security. :)
: [...] Still, if you _need_ the power of regular expressions, it's a good
: one; in this case, it's overkill, kind of like using your rifle to shut
: off the TV set, when the pliers are sitting right there.
ROFL! I prefer defenestrating it, personally, but TMTOWTDI...
: Regular expressions are powerful, but when index can be used, it will
: usually be better.
Actually, that's an interesting point of debate. Index, where applicable,
will almost always be *faster*...but it also forces a headspace change
when mixed in with other nearby code using regexes. It's really the sort
of thing that needs to be decided on a case-by-case basis.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 24 Jun 1997 22:24:02 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: checking for blanks
Message-Id: <5ophe2$i4a$1@marina.cinenet.net>
Ed Lufker (elufker@swcp.com) wrote:
: I have the need to check for blanks or alphanumeric data in $_,
: how would a line like that look in perl.
:
: I have something like this:
: $i[$x]=($_);
: if ($i[$x] == " ") I don't know what to put in the " ".
: Everything I have tried gives an error.
Have you read the Camel book? The Llama? The copious online help? Any
of these would have solved this faster than asking here.
A regex which is true for any string containing any blanks or any
alphanumeric data would look like /[\sA-Za-z0-9]/ (or the simpler
/[\s\w]/, if you're willing to accept underscore _ as well). Be sure to
chop or chomp input lines before applying this regex, or the \n will give
you a false positive by matching \s.
But I'm not sure how useful this would actually be...I can't help thinking
you've under- or mis-specificed your problem. Care to try again?
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Tue, 24 Jun 1997 15:17:59 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Douglas Wilson <dgwilson@gte.net>
Subject: Re: Delete specific element from list
Message-Id: <Pine.GSO.3.96.970624151346.24884E-100000@kelly.teleport.com>
On 24 Jun 1997, Douglas Wilson wrote:
> Calle Dybedahl wrote:
> > return grep { $_ ne $del } @arr;
> This is untested, but something like this might work for the
> return statement instead:
>
> return map { $_ == $del ? "" : $_ } @arr
In what way do you think that that is better? I can't see what would make
you think that.
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 24 Jun 1997 20:56:39 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Don Thomson <thomson@zinger.adp.wisc.edu>
Subject: Re: Efficiency of 'my' declaration w/in loop?
Message-Id: <Pine.GSO.3.96.970624205035.17167I-100000@kelly.teleport.com>
On 23 Jun 1997, Don Thomson wrote:
> I have a question about the relative expense of declaring a 'my'
> variable within a loop where it is used (assuming that it is a
> variable that will be reinitialized to 0 each time through the loop,
> and will not be used after the loop ends).
It's a good question. And the answer is: C<use Benchmark;>. To quote
Jeffrey Friedl,
When it comes down to it, the fastest program is the one that
finishes first. (You can quote me on that.)
So, use Perl's Benchmark module (or similar benchmarking code) and let us
know who is the winner! Thanks!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 24 Jun 1997 20:44:17 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: lloyd Vancil <lev@apple.com>
Subject: Re: forking without wait
Message-Id: <Pine.GSO.3.96.970624204240.17167G-100000@kelly.teleport.com>
On Tue, 24 Jun 1997, lloyd Vancil wrote:
> Is it possible in perl to fork a child using fork or system or ``,
> without having to wait for the child to exit?
Yes, when using fork (not the others). But you may want to read what the
FAQ says about avoiding zombies. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 24 Jun 1997 22:41:54 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: forking without wait
Message-Id: <5oq7ii$jd7@flatland.dimensional.com>
lloyd Vancil <lev@apple.com> writes:
> Is it possible in perl to fork a child using fork or system or ``,
> without having to wait for the child to exit?
If you use fork, the parent and the child will run concurrently -- the
the parent won't wait for the child unless you use the wait function.
Fork returns the child's process ID to the parent and 0 to the child;
here's an example:
$pid = fork;
die "couldn't fork: $!" unless defined $pid;
if ($pid) {
# parent
}
else {
# child
}
The parent and the child will run at the same time -- if you use
print statements in each, you'll see them intermingled (unless one
process happens to exit before the other one prints anything).
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: Tue, 24 Jun 1997 17:46:26 GMT
From: magnus.bodin@tychonides.se (Magnus Bodin)
Subject: Re: HTTPD:Authen
Message-Id: <33b1067b.2167216@news1.telenordia.se>
dgd@nebula.is.rpslmc.edu (Daniel G. Drumm) wrote:
>I answered my own question, this program works nicely to authenticate
>against a simple name:password field, using crypt(). Now, I just need one
>that I can tie into RSA or PGP.
>
>How would one encrypt the password on a web browser before it was sent
>across the network, if one was retrieving $password from a CGI?
That's the problem. If you follow the HTTP evolution, then you'll find
there is proposals on it's way for among others a MD5 digest auth
scheme.
I do not have this problem right now, but I'll solve it with a java
applet that contained the cryptology stuff.
This is very off-context here, but if you choose a java solution, I'll
really recommend you to take a look here for FREE java-classes
implementing DES, IDEA, Blowfish and SHA:
http://www.acme.com/java/software/
(Also support Bruce Schneider and buy the Applied Cryptography book
[Wiley])
Enough.
cheers
magnus
------------------------------
Date: Tue, 24 Jun 1997 17:55:44 +0200
From: Andre Pinheiro <ip201945@ip.pt>
Subject: Newbie question: 500 Server Error
Message-Id: <33AFEE00.37C7@ip.pt>
I have this script on my server, in the cgi-bin directory.
By the way, I have other .pl scripts there, and they all work fine.
The script is called "games_search.pl".
Here is its source:
----
#!/usr/local/bin/perl
&showHTML_header;
&showHTML_footer;
exit;
sub showHTML_header {
print 'Content-type: text/html' . "\n\n";
print '<HTML><HEAD><TITLE>xxxx</TITLE></HEAD>' . "\n";
print '<BODY TEXT="#000000" LINK="#008000" VLINK="#800000"
BGCOLOR="#FFFFCC">' . "\n";
print '<CENTER>' . "\n";
print '<IMG SRC="Images/Logo.jpg" WIDTH=272 HEIGHT=175 BORDER=0
ALT="xxxxxxx">' . "\n";
print '<BR>' . "\n";
print '<IMG SRC="Images/GreenBlackStripe.gif" WIDTH=536 HEIGHT=5><BR>'
. "\n";
print '<IMG SRC="Images/GreenBlackStripe.gif" WIDTH=536 HEIGHT=5>' .
"\n";
print '<P>' . "\n";
}
sub showHTML_footer {
print '<FONT SIZE=-1>' . "\n";
print 'Feedback:<BR>' . "\n";
print '<P>' . "\n";
print '</FONT>' . "\n";
print '</CENTER></BODY></HTML>' . "\n";
}
----
When I specify http://bla, bla, bla/cgi-bin/games_search.pl the browser
says:
----
500 Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator and inform them of the time the
error occurred , and anything you might have done that may have caused
the error.
Error: HTTPd: malformed header from script
/usr/local/etc/httpd/cgi-bin/games_search.pl
----
Can anyone tell me what's happening?
------------------------------
Date: Tue, 24 Jun 1997 21:18:56 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Subodh Desai <subodh@best.com>
Subject: Re: Perl "compiler" or how do you protect your code?
Message-Id: <Pine.GSO.3.96.970624211630.17167M-100000@kelly.teleport.com>
On 24 Jun 1997, Subodh Desai wrote:
> Is there some way to compile the perl code into an executable?
<sigh> See the FAQ.
I sigh because that's what the FAQ is for; it's a list of frequently asked
questions, and their answers. You didn't know that there was a list like
that, I know, or you would have checked it first. Well, at least you won't
make that mistake again. :-)
http://www.perl.org/CPAN/doc/FAQs/FAQ/html/perlfaq.html
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq.html
> Asked other way around -- if you make product that uses perl/cgi
> scripting extensively, how do you protect the perl source code which is
> part your product?
Put in a copyright notice. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 24 Jun 1997 15:13:28 +0200
From: "Miko3aj Morzy" <kola@cs.put.poznan.pl>
Subject: perl script on WinNT
Message-Id: <33AFC7F7.6A400B23@cs.put.poznan.pl>
on Unix machines every script begins with #!/usr/bin/perl or whatever
the path to the interpreter is. How does this line look like on Windows
NT machine (assuming interpreter perl386.exe)? I still get 500 server
error and I would appreciate your help.
Please help me- I'm getting more and more desperate
Kola
------------------------------
Date: Tue, 24 Jun 1997 21:29:10 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Wade Wegner <wwegner@uiuc.edu>
Subject: Re: PLEASE HELP A NEWBIE!!
Message-Id: <Pine.GSO.3.96.970624212353.17167P-100000@kelly.teleport.com>
On Tue, 24 Jun 1997, Wade Wegner wrote:
> Subject: PLEASE HELP A NEWBIE!!
Sure. Your first help is this: Check the frequent posting about choosing
good subject lines.
> the C script is called "check" and I'm trying to
> write it to a file called tmp. I tried:
>
> system ("$CHECKDIR/check > tmp");
>
> but that doesn't work.
Well, maybe you're not asking it to do what you think you're asking it to
do. Try this code instead.
$command = "$CHECKDIR/check >tmp";
warn "About to execute command '$command'";
warn "Hmmm... no write perms in current dir"
unless -w '.';
$result = system $command;
warn "Result code was $result";
Does that tell you anything interesting? Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 23 Jun 1997 17:18:24 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Q: an alternative to this use of "goto"?
Message-Id: <EC8o2o.7os@nonexistent.com>
Lloyd Zusman (asfast@asfast.com) wrote on 1392 September 1993 in
<URL: news:slrn5qs35c.bk0.asfast@ljz.asfast.net>:
++ On Sun, 22 Jun 1997 20:29:23 -0700, Craig Scrivner
++ <scrivner@gps.caltech.edu> wrote:
++ >
++ > START: {
++ > if (...) {
++ > ...
++ > }
++ > elsif (...) {
++ > ...
++ > redo START;
++ > }
++ > }
++
++ But aside from spelling "goto" as "redo" and requiring an extra level
++ of braces, how does this example differ from using "goto"?
You can't just jump anywhere. You can only jump to the beginning
(or end) of an enclosing block. It's like a goto, but with a limited
set of landing points.
You are right, this example doesn't differ from using 'goto'. But
there are examples of using 'goto' where it does matter.
++ The "goto" statement first fell into disfavor many years ago as part
++ of the philosophy of "modular programming". The above construct would
++ be considered just as undesirable by the proponents of modular
++ programming as the following construct.
++
++ START:
++ if (...) {
++ ...
++ }
++ elsif (...) {
++ ...
++ goto START;
++ }
Actually, the 'undesirable' case is a jump the other way:
foreach (1 .. 10) {
...
LABEL:
...
}
goto LABEL;
*That* is what makes goto considered harmful.
++ The extra level braces and the the word "redo" instead of "goto" do
++ not change the basic flaw in this construct from the point of view of
++ those who strictly adhere to the philosophy of modular programming.
++
++ Here is one of several ways that these strict adherents of modular
++ programming would write the above construct:
++
++ for (;;) {
++ if (...) {
++ ...
++ last;
++ }
++ elsif (...) {
++ ...
++ }
++ else {
++ last;
++ }
++ }
But that does the same, doesn't? It isn't the syntax that matters,
it's the semantics. With goto, you can have:
{ ...
LABEL1:
...
}
{ ...
goto LABEL1
...
}
You can't simulate that with last/redo.
++ And here's another variation that would be acceptable to the strict
++ modular programming crowd:
++
++ $looping = 1;
++ while ($looping) {
++ $looping = 0;
++ if (...) {
++ ...
++ }
++ elsif (...) {
++ ...
++ $looping = 1;
++ }
++ }
++
++ There are other variations, as well.
++
++ The don't-ever-ever-ever-use-"goto"-no-matter-what movement has lost
++ some of its dogmatic fervor over the past decade, and people are a bit
++ more relaxed and practical about this issue nowadays. Today's
++ acceptability of the "redo" construct is evidence of this.
'redo' is just a way to avoid writing twisted constructs as the
above. (Although I guess code with redo's would be harder to prove
correctly.)
++ Therefore, it's my opinion that if you really want to use that "redo"
++ construct, you might as well just leave off the extra braces and spell
++ "redo" as "goto".
Nope, redo is a limited goto. You can simulate redo with goto, but
you can't simulate goto with redo.
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=$]*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Mon, 23 Jun 1997 11:21:08 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Q: an alternative to this use of "goto"?
Message-Id: <Pine.GSO.3.96.970623112025.9838S-100000@kelly.teleport.com>
On 23 Jun 1997, Lloyd Zusman wrote:
> But aside from spelling "goto" as "redo" and requiring an extra level
> of braces, how does this example differ from using "goto"?
redo will be implemented in the compiler and future versions of Perl; the
future of goto is much more in doubt. Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 24 Jun 1997 20:50:11 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Q: an alternative to this use of "goto"?
Message-Id: <Pine.GSO.3.96.970624204432.17167H-100000@kelly.teleport.com>
[ Lloyd, you shouldn't hide it that you posted this as well; I wasted time
replying privately before this arrived at my site. ]
On 25 Jun 1997, Lloyd Zusman wrote:
> On Tue, 24 Jun 1997 10:05:26 -0700, Tom Phoenix <rootbeer@teleport.com>
> wrote:
> > There's no need to spend lots of time and energy optimizing goto,
> > since it's used quite rarely, and it should never be used when
> > efficiency is an issue.
>
> But that's a circular argument. If "goto" were well optimized, then
> there wouldn't be a problem using it when efficiency is an issue.
If you'd like to see it optimized, feel free to submit a patch. Nobody's
opposed to optimizing it, but there are a lot of things higher on the
priority list, that's all.
But I'm not going to take up the pro-goto versus anti-goto argument here;
that's been argued by bigger brains than ours, and I don't think we're
going to improve the world any by further debate.
Thanks for writing!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 23 Jun 1997 18:24:25 GMT
From: kevinz@gazette.stortek.com (Kevin Zwack)
Subject: Q: List/scalar context with methods
Message-Id: <5omf0p$2i7$1@news.stortek.com>
Hi all,
I hate to ask what might be a duumb question, but it's Monday and
I'm stumped. In the following code snippet...
use CGI qw(:standard);
$Q = new CGI;
$Q->use_named_parameters(1);
$Q->append(name => 'foo',
values=> ['one', 'two', 'three']);
What I what to be able to do is determine how many elements
$Q->param('foo') will return. I could do this:
@foo = $Q->param('foo')
if (scalar(@foo) == 3) ...
but this creates an extra array which seems wasteful. After
studying "the book", I was able to come up with this:
if (scalar(@{[$Q->param('foo')]}) == 3) ...
which works but hurts my eyes to read. Is there any
simpler or more elegant means of doing this?
Thanks in advance,
Kevin Zwack
--
Kevin Zwack
Storage Technology Corporation
Lousiville, Colorado
kevinz@model-t.stortek.com
------------------------------
Date: Tue, 24 Jun 1997 21:20:46 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Mousheng Xu <mxu@eecs.ukans.edu>
Subject: Re: Q: MacPerl, MacHTTP and CGI
Message-Id: <Pine.GSO.3.96.970624212007.17167N-100000@kelly.teleport.com>
On Tue, 24 Jun 1997, Mousheng Xu wrote:
> I installed machttp and MacPerl and I have some unix perl scripts.
> But how I don't know how to convert the unix perl to mac perl.
This should be covered in the documentation which comes with MacPerl. If
you read that and still have questions, please ask again. Thanks!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 24 Jun 1997 20:41:10 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Vince Betro <vinbetro@vantek.net>
Subject: Re: Quick PERL Quesiton
Message-Id: <Pine.GSO.3.96.970624203751.17167F-100000@kelly.teleport.com>
On Tue, 24 Jun 1997, Vince Betro wrote:
> I didn't get a thing you said Tom. I am just a beginer.
Okay, I'll try saying it a different way.
See what you can find in the hundreds of pages of free documentation which
come with Perl. (I'm not exaggerating when I say hundreds of pages. Dozens
of people have worked thousands of hours putting together an amazing body
of information, and they give it to you for free!) There are manpages,
FAQs, and example programs.
Once you've done that, if you still have questions, please post again;
your questions are welcome here, and lots of us want to help you and
others to learn and use Perl. Good luck with your projects!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 24 Jun 1997 14:00:09 GMT
From: quentin@remington.amd.com (Quentin Fennessy)
Subject: Re: regular expressions
Message-Id: <5oojt9$4g8$1@amdint2.amd.com>
In article <EC93uB.How@seas.ucla.edu>,
Tri Tram <tram@olympic.seas.ucla.edu> wrote:
>
> Can somebody please help me with the regular expressions? I have the
>following:
>text #(text)
>text #(more test)
>test #(text and more text)
>
>I want to change it to:
>text add_text(text)
>text add_text(more_text)
>test add_text(text_and_more_text)
Tri,
Try this:
s/ #\(/ add_text(/;
--
Quentin Fennessy AMD, Austin Texas
------------------------------
Date: Tue, 24 Jun 1997 23:04:16 -0600
From: graham.staker@wmc.com.au
Subject: system call
Message-Id: <867208586.30365@dejanews.com>
Here is another system call problem (c.f. Patrick Lim).
On the command line the script runs normally and the return status of
the system call is 0.
In CGI however the return status is 35584 (0x8B00), inferring signal
status 0 and child process status 139. This is occurring under Solaris
2.5 but the <sys/errno.h> file is unhelpful in that error numbers in the
range 135-142 are allocated to Xenix (where 139 would mean "is a named
type file").
Does anyone know what this error code really means in this context?
The child process is a plotting program (gnuplot) which directs its output
to a selected graphics format file.
Thanks in advance.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Mon, 23 Jun 1997 18:19:25 GMT
From: khawkins@sconcepts.com (Katrina Hawkins)
Subject: USA-NYC-UNIX/SYBASE/PERL CONSULTING OPPORTUNITY
Message-Id: <5omedv$du2$1@news2.i-2000.com>
Spectrum Concepts Consulting Corp. has been providing consulting
expertise to the New York area since 1979.
We currently have an opportunity for a senior developer with
experience in Perl 5.0, Sybase and Unix to work an Investment Bank.
This is a 3mth+ opprtunity.
For more information about this position or to refer a collegue(we pay
$1000+ referral fees!!), please contact:
Katrina Hawkins
Technical Recruiter
Spectrum Concepts Consultiing Corp.
150 Broadway, Suite 600, New York, NY 10038
Ph: (212) 791 4800 x249
Fax: (212) 791 6639
Email khawkins@sconcepts.com
www.sconcepts.com
------------------------------
Date: Tue, 24 Jun 1997 21:23:39 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Andrew Starr <atspublic@bigfoot.com>
Subject: Re: Validating E-Mail addresses and URL's
Message-Id: <Pine.GSO.3.96.970624212116.17167O-100000@kelly.teleport.com>
On Tue, 24 Jun 1997, Andrew Starr wrote:
> I'm no expert, but I think for my needs for "validating" e-mail
> addresses, I'm happy if I just look for non-null, or perhaps an @ sign,
Please don't start this discussion again. At least, not without reading
the archives of what's already been said about validating e-mail
addresses. It's been discussed so much that anything more is almost
certainly a waste of bandwidth.
Thanks!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.
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 658
*************************************