[8450] in Perl-Users-Digest
Perl-Users Digest, Issue: 2067 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 10 20:07:46 1998
Date: Tue, 10 Mar 98 17:00:35 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 10 Mar 1998 Volume: 8 Number: 2067
Today's topics:
"system" command from perl failing (NT)? (William Gray)
array question mchunziker@us.fortis.com
Re: beginner troubles <sowmaster@juicepigs.com>
Re: Brand new and completely bewildered!!! (Matthew Cravit)
Re: Brand new and completely bewildered!!! scott@softbase.com
Re: c.l.p.mod and TPI (I R A Aggie)
Re: c.l.p.moderated, TPI, and c.l.p.announce (A. Deckers)
Re: Calculating DOW <rhawkins@navix.net>
Re: Can a Perl CGI get and read another HTML doc to par <rkturner@us.ibm.com>
Re: CGI-Forms Question (I R A Aggie)
Re: comp.lang.perl.moderated (was Re: Tom, grow up [Re: (Earl Hood)
Re: deleting an element (Gabor)
E-Mail priority? <mknutson@websolution.com>
Re: Help wanted (Craig Berry)
Re: in the name of Baby Jesus PLEASE HELP ME... <beadles@nortel.com>
Re: Local File handles? (Andrew M. Langmead)
Re: Looking for program that reverses email addresses (Hunter Johnson)
Multiline formats <jhohl@nfs-edgar.com>
Re: pod2man and solaris catman <th@ccn.net>
Re: Problem with "goto" in Perl (Mike Stok)
Re: Problem with "goto" in Perl (Steve Linberg)
Re: Problem with "goto" in Perl (Andrew M. Langmead)
Re: Problem with "goto" in Perl (Mike Stok)
Re: Problem with "goto" in Perl <uri@sysarch.com>
Q: Can a Perl CGI get and read another HTML doc to pars <printplus@zippy.intcom.net>
Re: Q: Can a Perl CGI get and read another HTML doc to (Steve Linberg)
Re: Skipping within a line to read URL? (Craig Berry)
Re: Speed of sort routine vs. one-by-one compare (123 (Abigail)
Re: Speed of sort routine vs. one-by-one compare (123 <uri@sysarch.com>
Re: The -w switch (was Re: better way to do this?) (Mike Heins)
Re: using a scalar in an expression mchunziker@us.fortis.com
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 10 Mar 1998 23:28:24 GMT
From: smiths@alumni.cse.ucsc.edu (William Gray)
Subject: "system" command from perl failing (NT)?
Message-Id: <slrn6gbj6d.e8t.smiths@alumni.cse.ucsc.edu>
I have encountered a problem where system commands from my
perl script don't work under NT if I start the script remotely
via rexec. For example:
@list = `dir`;
returns nothing if invoked remotely.
Works fine if the script is started locally from NT.
I've tried two different perl32 distributions with
the same results. I suspect the environment is not correct
for perl when started from the rexec daemon. Anyone have any
ideas what might cause perl to have trouble with system commands?
Thanks,
-Wes
--
"Sigourney Weaver is pretty cool, he really kicks ass in all those
alien movies, even if he does look a little like a chick."
------------------------------
Date: Tue, 10 Mar 1998 16:25:11 -0600
From: mchunziker@us.fortis.com
Subject: array question
Message-Id: <6e4ei5$6up$1@nnrp1.dejanews.com>
Perhaps this can't be done since I can't find a reference in
Camel, Llama or TYP 21 days......
I would like to scan the /dev directory for vg?? and stuff them into
an array or scaler....no problem so far...easy enough....but I also want to
create a new array based on a variable...in other words if I find vg00
I want to create a @vg00 array. Is there a way to create an array using
a variable...I've been unable to figure out a way to do it without a bunch
of if's and elsif's....I know something silly like @$VG= isn't going to
get me very far! Thanks in advance....
mchunziker@us.fortis.com
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Tue, 10 Mar 1998 19:20:05 -0500
From: Bob Trieger <sowmaster@juicepigs.com>
To: El Penguino <penguin@tiac.net>
Subject: Re: beginner troubles
Message-Id: <3505D8B5.6A0E@juicepigs.com>
El Penguino wrote:
>
> I'm trying to learn CGI w/Perl on my own. I downloaded the Perl 5
> interpreter (on my Win95 PC) but looking at all these readme
> instructions I'm totally lost. Would someone be willing to call me on
> the phone and talk me through this mess. Please reply then I'll reply
> with my phone number. Thanks.
Pick up a copy of "Learning Perl" by Randal L. Schwartz. It is very
simple to follow and after you have a handle on things it makes a great
reference.
For more info on the book or to order it online goto
http://www.oreilly.com/publishing/perl/
HTH
Bob Trieger
sowmaster@juicepigs.com
------------------------------
Date: 10 Mar 1998 14:33:13 -0800
From: mcravit@shell3.ba.best.com (Matthew Cravit)
Subject: Re: Brand new and completely bewildered!!!
Message-Id: <6e4f39$ads$1@shell3.ba.best.com>
In article <889559883.17693.0.nnrp-01.9e984532@news.demon.co.uk>,
Sarah Medway <sarah@shiver.demon.co.uk> wrote:
>I have bought 'Perl 5 for Dummies', 'The CGI/ Perl Cookbook' (which does
>have a script, but I don't understand how to configure it!) and 'Perl CGI
>Programming, no experience required'. All of them seem to go from ABC into
>rocket science in the space of one page.
I would suggest the following two books, which I think will give you a MUCH
better understanding of what you're doing (especially if you have little or
no prior programming experience):
- "Learning Perl, 2nd edition"
By Randall Schwartz and Tom Christiansen
Publisher: O'Reilly & Associates
ISBN: 1-56592-284-0
- "CGI Programming on the World Wide Web"
By Shishir Gundavaram
Publisher: O'Reilly & Associates
ISBN: 1-56592-168-2
Both books are about $30 each, and will (I think) give you a very good start.
On the other hand, programming in any language is generally a non-trivial
task, and you WILL have to invest some time learning what you're doing.
But those books will give you most of the basic skills you'll need for the
kind of project you described.
Hope this helps.
/MC
--
Matthew Cravit, N9VWG | Experience is what allows you to
E-mail: mcravit@best.com (home) | recognize a mistake the second
mcravit@net.com (work) | time you make it.
------------------------------
Date: 10 Mar 1998 22:11:01 GMT
From: scott@softbase.com
Subject: Re: Brand new and completely bewildered!!!
Message-Id: <6e4dpl$o1s$2@scully.new-era.net>
Sarah Medway (sarah@shiver.demon.co.uk) wrote:
> But, however, I am completely brand new to Perl.
> I have bought 'Perl 5 for Dummies'...
> Am I being to ambitious to even contemplate doing this...
Unless you are an *extremely* fast learner, you're in way
over your head. You need to get a good Perl book
like Learning Perl (throw the Dummies stuff in the trash)
and learn the basics before even starting CGI programs.
> ... as it is a skill that takes years to master?
With no prior UNIX experience with regular expressions and
grep, awk, sed or similar utilities I'd say years would be
accurate. Most people who learn Perl faster already know a little
awk and C. If you're starting from scratch, Perl is a
formidible language simply because it draws from so many
sources.
Even if you know Perl, you still have to learn CGI programming.
That alone is very difficult, since every machine has a different
way of handling it.
Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more.
------------------------------
Date: Tue, 10 Mar 1998 17:33:14 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: c.l.p.mod and TPI
Message-Id: <fl_aggie-1003981733150001@aggie.coaps.fsu.edu>
In article <pudge-1003981427420001@ppp-32.ts-1.kin.idt.net>,
pudge@pobox.com (Chris Nandor) wrote:
+ In article <889525385.976597@cabal>, ? the platypus {aka David Formosa}
+ <dformosa@st.nepean.uws.edu.au> wrote:
+
+ # Then why is the bord of TPI acting as defacto moderators? We already have
+ # a moderation panel, it should be there job to decide what is or is not
+ # apporate to a newsgroup.
+
+ Sigh. Not one person on TPI's board was listed as one of the moderators.
+ What, you mean the provision that TPI can post "ads" makes it a
+ moderator? That is nonsensical.
The way I read the proposed charter, TPI can post pretty much whatever
it wants whenever it wants, bounded by "of interest to the general
perl community".
Well, actually not, now that I've re-read it. It _just_ looks that way.
The paragraph in question is somewhat ambigous, and probably needs to be
re-written.
Suggested wording:
+ which contains an advertisement or commercial solicitation
of any sort; (EXCEPTION: Commercials may posted that the
moderators deem to be of general interest to the Perl
community, such as announcements of upcoming Perl-oriented
conferences.)
I think this ought to silence the objections to this section.
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>
------------------------------
Date: 11 Mar 1998 00:07:15 GMT
From: alain.deckers@man.ac.uk (A. Deckers)
Subject: Re: c.l.p.moderated, TPI, and c.l.p.announce
Message-Id: <slrn6gbldj.mbu.alain.deckers@nessie.mcc.ac.uk>
(followup)
In <8ciupmsd3e.fsf_-_@gadget.cscaper.com>,
Randal Schwartz <merlyn@stonehenge.com> wrote:
[comp.lang.perl.announce]
>The approved charter says "comp.lang.perl.announce will be a
>low-volume, moderated group for announcements of new releases of perl
>or its extensions (oraperl, sybperl, etc.) and periodic postings
>related to perl."
>
>I don't see anything in there that permits conference or book
>announcements.
If the conferences and books are related to perl, then their
annoucements qualify as "periodic postings related to perl." Case
closed.
Alain
--
Introduction to news.groups:
<URL:http://www.cybernothing.org/faqs/new-users-please-read.txt>
Guidelines for Usenet Group Creation:
<URL:ftp://rtfm.mit.edu/pub/faqs/usenet/creating-newsgroups/part1>
------------------------------
Date: 10 Mar 1998 23:59:49 GMT
From: "Ron Hawkins" <rhawkins@navix.net>
Subject: Re: Calculating DOW
Message-Id: <01bd4c4d$89c00ee0$14ea9ece@hawk233>
>Phil Heinz <heinz@platinum.com> wrote in article
> I'm trying to determine a day of week for a particular date that is read
in
> via any date format by my program. I'm assuming I'll have to convert
their
> format into a gmtime type to do the localtime function? How can I
accomplish
> this task?
>
Here is a snippet of some of my code to get the day of the week. I also
have an array set up for the Month name, etc.
--Ron
==== start code ======
#!c:\perl\bin\perl.exe
my(@DoW) = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
my($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);
my($TZ) = defined($ENV{'TZ'}) ? ( $ENV{'TZ'} ? $ENV{'TZ'} : 'GMT' ) : '';
my $time = time();
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
($TZ eq 'GMT') ? gmtime($time) : localtime($time);
printf("DOW = %s\n", $DoW[$wday]);
==== end code =====
> The code for translating this date is done, I just can't get a gmtime
> variable created.
>
> Thanks !!!!
> Phil
>
>
>
------------------------------
Date: Tue, 10 Mar 1998 17:46:20 -0600
From: "Keith Turner" <rkturner@us.ibm.com>
Subject: Re: Can a Perl CGI get and read another HTML doc to parse it?
Message-Id: <6e4jc0$1ghm$1@ausnews.austin.ibm.com>
go to:
http://www.perl.com/CPAN-local//modules/by-module/WWW/
and get libwww-perl-X.XX-tar.gz. This should do it for you... I used it to
do GET's from HTTP servers. Took a while to figure it out, the
documentation was still in the works when I used it.
------------------------------
Date: Tue, 10 Mar 1998 17:21:34 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: CGI-Forms Question
Message-Id: <fl_aggie-1003981721340001@aggie.coaps.fsu.edu>
In article <35069dff.423427115@news.newsguy.com>, dave@cybersigns.com
(Dave) wrote:
+ Using cgi-lib/Perl5 W32
Use CGI.pm instead.
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>
------------------------------
Date: 10 Mar 1998 20:16:44 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: comp.lang.perl.moderated (was Re: Tom, grow up [Re: The -w switch (was Re: better way to do this?)])
Message-Id: <6e473c$bb0@news.service.uci.edu>
In article <8cra4bwqoa.fsf_-_@gadget.cscaper.com>,
Randal Schwartz <merlyn@stonehenge.com> wrote:
>
>A "non-profit" corporation with "commercial interests"? Where did you
>get your dictionary?
I believe the intent is: members of a "non-profit" corporation can have
self-serving "commercial interests". Many non-profit organizations
have commercial members and sponsers, and their reasons for
joining/sponsering is usually for commercial reasons. I.e. An
organization can be non-profit, but its members are for-profit. How
many companies state "We're part of the XXX group" (and XXX group is
classified as "non-profit") as a selling ploy to obtain profits.
"non-profit" does not imply any form of philosophy (in our society).
I believe the government has a strict meaning of "non-profit", and I
bet it deals with finances, revenues, and taxes, and not philosophy.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: 10 Mar 1998 21:57:27 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: deleting an element
Message-Id: <slrn6gbefs.5gd.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Bayweb Designs <info@baywebdesigns.com> wrote :
# --
# I need to delete a line, $match, out of an array. Suppose my array was:
# @a = ("one","two","three","four","five");
# $match =3;
# I have to get element number 3 out of the array. Can you give me some
# example code?
splice @a,3,1;
------------------------------
Date: Tue, 10 Mar 1998 14:58:41 -0800
From: Mick Knutson <mknutson@websolution.com>
Subject: E-Mail priority?
Message-Id: <3505C5A1.FBFC6641@websolution.com>
I have a form I send to a perl script. I format this form, and generate
an e-mail to a specified user. How can I set the priority of that
messsage to something other than normal. Say High or Low priority.
------------------------------
Date: 10 Mar 1998 21:58:39 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Help wanted
Message-Id: <6e4d2f$5qb$2@marina.cinenet.net>
philip Martin (philip@pmwd.com) wrote:
: while(<SCRIPT>){
: $name .= $_;
: }
Or, far more efficiently,
undef $/;
$name = <SCRIPT>;
---------------------------------------------------------------------
| 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, 10 Mar 1998 17:26:17 -0600
From: "John T. Beadles" <beadles@nortel.com>
Subject: Re: in the name of Baby Jesus PLEASE HELP ME...
Message-Id: <3505CC19.1D89FE1B@nortel.com>
Abigail wrote:
>
> Aditya (mishra.aditya@emeryworld.com) wrote on 1647 September 1993 in
> <URL: news:6dmrm8$pdo@ljcqs003.cnf.com>:
> ++
> ++ If you are a prisoner of the Evil Empire and your dummy.exe resides in
> ++ c:\tmp the
> ++ command would be
> ++ system("c:\tmp\dummy.exe")
>
> I don't think so. (A *tab* in the second position?)
>
> system "c:/tmp/dummy.exe"; works fine, even on MS systems.
>
> Abigail
> --
> perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT
for that matter,
`c:/tmp/dummy.exe`;
works just fine too
--
------------------------------------------------
John T. Beadles Nortel CDMA RF Design
Office: 972-685-7813 Fax: 972-684-3767
Email (office): beadles@removethis.nortel.com
Any opinions are mine and to do not represent
those of my employer
------------------------------------------------
------------------------------
Date: Tue, 10 Mar 1998 23:00:10 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Local File handles?
Message-Id: <EpML8A.Cxy@world.std.com>
Scott Starks <scotts@ptp.hp.com> writes:
>I have a subroutine that recursively calls itself. It has the potential
>to open a file handle in each call. Is there a way to make this file
>handle local (ie my) to the function so that each recursive call to the
>function has it's own copy of the file handle?
Use the IO::Handle module to make a filehandle that can be stored in a
scalar.
use IO::Handle;
my $handle = IO::Handle::new('filename') or die;
Or use one of the methods described in "How can I make a filehandle
local to a subroutine? How do I pass filehandles between subroutines?
How do I make an array of filehandles?" <URL:http://www.perl.com/CPAN/
doc/manual/html/pod/perlfaq5/How_can_I_make_a_filehandle_loca.html>
--
Andrew Langmead
------------------------------
Date: 10 Mar 1998 22:09:33 GMT
From: jhunterj@lexis-nexis.com (Hunter Johnson)
Subject: Re: Looking for program that reverses email addresses
Message-Id: <6e4dmt$njv@mailgate.lexis-nexis.com>
In article <350514E3.32F4@itworks.be>,
Patrick Van Renterghem <pvr@itworks.be> wrote:
> Hence, we are looking for a program that reverses email addresses, and
> turns e.g. pvr@itworks.be into be-itworks-pvr, from where we can take
> further action to count similar occurrences, etc. The email adress can
> be embedded in lines like
> Patrick Van Renterghem <pvr@itworks.be>
> pvr@itworks.be (Patrick Van Renterghem)
You've got two tasks:
1: extract the email address
2: Reverse a Line by Words (Common Tasks With Perl)
See DejaNews for pulling (valid) email addresses.
Assuming the input is one email address per line:
perl -n -e 'chop; print join("-", reverse split(/[.@]/)), "\n";'
Hunter
--
J. Hunter Johnson /\ SJG Errata Coordinator (sjg-errata@io.com)
http://www.io.com/~jhunterj/ /()\ Knightmare Chess Development Coordinator
jhunterj@io.com /____\ The Games of '98 by # of times played:
Gin LamPoker Pitch Brain Robo Crib GrPrix ModArt EmpBuild SplitSec KC Catan
------------------------------
Date: Tue, 10 Mar 1998 19:51:08 -0500
From: Jim Hohl <jhohl@nfs-edgar.com>
Subject: Multiline formats
Message-Id: <3505DFFC.700F@nfs-edgar.com>
On a web page, I have an input form where users can enter paragraphs of
information in a form field. This data is then printed out using the
"write" command into a certain format which must wrap to 80 characters
wide.
The standard multiline reporting format command "@*" does not wrap the
output and formatting with "^<(x80)~~" drops any input after a newline
and moves on to the next record.
Is it possible to either wrap the output of "@*" or change the record
separator character in "^<"?
Thanks.
(Does this make any sense?)
--
Jim Hohl
National Filing Services, Inc.
jhohl@nfs-edgar.com
http://www.nfs-edgar.com
+1 (212) 732-0045
------------------------------
Date: Wed, 11 Mar 1998 00:11:09 +0100
From: Tassilo Hofmann <th@ccn.net>
Subject: Re: pod2man and solaris catman
Message-Id: <3505C88D.69A38A50@ccn.net>
Hello,
Hmm... pod2man's output might not be what catman expects, but seems to
meet nroff's expectations quite well ;-) if you have JDK 1.1 installed
(or Solaris 2.6) I suggest typing 'apropos java' to see how nicely Sun's
own man pages are indexed by catman.
I rather thought of writing a replacement for Solaris' 'catman -w' using
Perl. Perhaps this has already be done by somebody?
Regards
Tassilo
Christian Gilmore wrote:
>
> The output of pod2man does not produce what catman expects and hence does
> not allow catman to properly index the perl man pages. Those man pages that
> are not portions of a module (ie, IO::Socket) are indexed but do not have
> the proper section information. Those that are portions of a module have
> "NAME" or Header or .IX as their names and .IX as their section according
> to windex.
>
> Has anyone found a fix for this apparent brokenness of pod2man?
>
> Regards,
> Christian
------------------------------
Date: 10 Mar 1998 22:25:31 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Problem with "goto" in Perl
Message-Id: <6e4ekr$dqq@news-central.tiac.net>
In article <linberg-1003981539060001@projdirc.literacy.upenn.edu>,
Steve Linberg <linberg@literacy.upenn.edu> wrote:
>I use GOTO quite a lot (after about 15 years of avoiding it like the
>plague) in circumstances where there are many steps being taken in a
>function, each of which may fail, and where simply quitting with an error
>code isn't an option becuase there is cleaning up to do first.
>It could be done with nested conditionals, but after about 4 layers deep
>the code becomes unreadable. Which is cleaner?
>if (cond1) {
> blah
> blah
> if (cond2) {
> blahblah
> if (cond3) {
> blahblahblah
> blahblahblah
> if (cond4) {
> blahblah
> blahblah
> if (cond5) {
> blah # repeat a few more layers
> }
> }
> }
> }
>} # and we aren't even bothering with else
>
>or
using a bare block in pseudo perl:
LABEL:
{
last LABEL unless cond1;
blah;
blah;
last LABEL unless cond2;
blahblah;
last LABEL unless cond3;
blahblahblah;
}
cleanup;
return;
Maybe,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Tue, 10 Mar 1998 17:30:22 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Problem with "goto" in Perl
Message-Id: <linberg-1003981730220001@projdirc.literacy.upenn.edu>
In article <6e4ekr$dqq@news-central.tiac.net>, mike@stok.co.uk (Mike Stok)
wrote:
> using a bare block in pseudo perl:
>
> LABEL:
> {
> last LABEL unless cond1;
> blah;
> blah;
> last LABEL unless cond2;
> blahblah;
> last LABEL unless cond3;
> blahblahblah;
> }
> cleanup;
> return;
Hm! Yes, I keep forgetting that I can do things like this in Perl. Cool.
However, it does raise the question: is this less evil then goto, and if
so, why?
_____________________________________________________________________
Steve Linberg National Center on Adult Literacy
Systems Programmer &c. University of Pennsylvania
linberg@literacy.upenn.edu http://www.literacyonline.org
------------------------------
Date: Tue, 10 Mar 1998 22:53:02 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Problem with "goto" in Perl
Message-Id: <EpMKwE.88q@world.std.com>
linberg@literacy.upenn.edu (Steve Linberg) writes:
> goto exit1 if (!cond1)
> blah
> blah
> goto exit1 if (!cond2)
> blahblah
> goto exit1 if (!cond3)
> blahblahblah # etc.
>exit1:
> clean up
> return
But in perl, you can say:
TRY: {
last TRY if (!cond1)
blah
blah
last TRY if (!cond2)
blahblah
last TRY if (!cond3)
blahblahblah # etc.
}
clean up
return
Using a loop modifer at least gives your program some bounds in which
it is branching to.
--
Andrew Langmead
------------------------------
Date: 11 Mar 1998 00:19:57 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Problem with "goto" in Perl
Message-Id: <6e4lbd$ilq@news-central.tiac.net>
In article <linberg-1003981730220001@projdirc.literacy.upenn.edu>,
Steve Linberg <linberg@literacy.upenn.edu> wrote:
>Hm! Yes, I keep forgetting that I can do things like this in Perl. Cool.
>
>However, it does raise the question: is this less evil then goto, and if
>so, why?
goto is just a tool in the perl toolbox. I prefer the bare block with a
label 'cos there's a nice contained scope defined by the block's braces.
goto LABEL has its place, but its place is rarely encountered in perl as
there are so many other ways of controlling flow.
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: 10 Mar 1998 19:31:40 -0500
From: Uri Guttman <uri@sysarch.com>
To: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Problem with "goto" in Perl
Message-Id: <x77m62ukyb.fsf@sysarch.com>
linberg@literacy.upenn.edu (Steve Linberg) writes:
> In article <6e4ekr$dqq@news-central.tiac.net>, mike@stok.co.uk (Mike Stok)
> wrote:
>
> > using a bare block in pseudo perl:
> >
> > LABEL:
> > {
> > last LABEL unless cond1;
> > blah;
> > blah;
> > last LABEL unless cond2;
> > blahblah;
> > last LABEL unless cond3;
> > blahblahblah;
> > }
> > cleanup;
> > return;
>
> Hm! Yes, I keep forgetting that I can do things like this in Perl. Cool.
>
> However, it does raise the question: is this less evil then goto, and if
> so, why?
because goto was invented by uncle bill, lord of the evil empire :-)
perl block labels are much less evil for several reasons (gang, correct
me if i don't get them all):
more efficient since perl goto scans the code for the label, while a last
LABEL knows the block it is exiting.
cleaner code is obvious. programmers (especially C) have long longed for
a clean nested loop/block exit. larry finally created a good design.
this technique can be nested as deep as you want and any statement can
exit any labeled block. also you can use next as well to perform the
next loop of any labeled loop.
there is also the continue block (not C continue. that is perl next)
which is executed by next before the conditional is executed again. you
could put loop or block cleanup or tracking code there and exit cleanly
to it from anywhere in the (nested) loops/blocks. another larry jewel.
also there is redo which will execute the loop/block again without
executing the continue block OR the conditional.
however you want to do it, you NEVER should need or use GOTO. larry
covered all the needed cases.
all of this is from blue camel pages 102-103.
HTH,
uri
--
Uri Guttman SYStems ARCHitecture and Software Engineering
uri@sysarch.com Have Perl, Will Hack
http://www.sysarch.com (781) 643-7504 x*2 FAX: (781) 643-2710
Try the Best Search Engine on the Net --------> http://www.northernlight.com
------------------------------
Date: Tue, 10 Mar 1998 17:10:24 -0500
From: Ed Arnold <printplus@zippy.intcom.net>
Subject: Q: Can a Perl CGI get and read another HTML doc to parse it?
Message-Id: <3505BA47.748D@zippy.intcom.net>
Q: Can a Perl CGI get and read another HTML doc to parse it?
I'd like to find a way of getting information from another HTML or FTP
source (weather data) and repeat it (formatted my way) in an Perl script
CGI. How do I get my script to GET and read an HTML document (via HTTP,
I presume).
OR -- Maybe you know the answer to this question. How can one get
current weather data in a dynamically-created page. I can create the
page, but have yet to find or develop the weather gathering capability
from some weather server somewhere.
Ed
edarnold@one.net
printplus@zippy.intcom.net
------------------------------
Date: Tue, 10 Mar 1998 17:33:09 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Q: Can a Perl CGI get and read another HTML doc to parse it?
Message-Id: <linberg-1003981733090001@projdirc.literacy.upenn.edu>
In article <3505BA47.748D@zippy.intcom.net>, printplus@zippy.intcom.net wrote:
> Q: Can a Perl CGI get and read another HTML doc to parse it?
> I'd like to find a way of getting information from another HTML or FTP
> source (weather data) and repeat it (formatted my way) in an Perl script
> CGI. How do I get my script to GET and read an HTML document (via HTTP,
> I presume).
The Perl Journal, volume 1, issue 4 (december 1996) has a column by
Lincoln Stien (p. 21-22) that does exactly this. You should order the
back issues and subscribe if you want an insanely useful resource and
repository of Perl wisdom.
http://www.tpj.com
_____________________________________________________________________
Steve Linberg National Center on Adult Literacy
Systems Programmer &c. University of Pennsylvania
linberg@literacy.upenn.edu http://www.literacyonline.org
------------------------------
Date: 11 Mar 1998 00:28:43 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Skipping within a line to read URL?
Message-Id: <6e4lrr$f9l$1@marina.cinenet.net>
Shaila V. Kulkarni (skulk@Glue.umd.edu) wrote:
: I am having trouble with the following bit and really don't know why my
: code isn't working.
Showing your code would help us figure out why. Otherwise, see
comp.lang.perl.psychic-friends. :)
: This line is present in a file i need to read:
:
: [Sun Feb 1 00:07:38 1998] access to /homes/kanlis/public_html/Greek/grlinks.htm
: l failed for neh116.pdx.oneworld.com, reason: File does not exist
:
: I need to grab only the URL. there are several thousand of these lines and
: the URLs vary in length. obviously some have more '/' than others.
Well, if the words 'access to' always precede the url, and it never has
internal spaces (which I believe you can count on for urls), you can do it
inelegantly yet effectively with:
my ($url) = $line =~ /access to\s+(\S+)/;
Alternatively, you can hook it on that first slash, if you're more
comfortable guaranteering that every url starts with a slash, and no
slashes precede the url in the line:
my ($url) = $line =~ m!(/\S+)!;
HTH!
---------------------------------------------------------------------
| 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: 10 Mar 1998 22:21:47 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Speed of sort routine vs. one-by-one compare (123)
Message-Id: <6e4edr$rj9$1@client2.news.psi.net>
Uri Guttman (uri@sysarch.com) wrote on 1652 September 1993 in
<URL: news:x7afayuzlb.fsf@sysarch.com>:
++ abigail@fnx.com (Abigail) writes:
++
++ > Nick Halloway (snowe@rain.org) wrote on 1652 September 1993 in
++ > <URL: news:Pine.SUN.3.96.980309211528.26290A-100000@coyote.rain.org>:
++ > ++
++ > ++ Yes, it would be kept sorted, and each time a new record is added it
++ > ++ would be put into the right place. If anyone has a binary sort
++ > ++ routine to do this that would be plenty quick, I'm sure.
++ >
++ > What is a binary sort routine?
++
++ abby, i am surprised you asked this. binary sorts are among the first
++ algorithms i ever learned (too many years ago).
I know what binary _search_ is, but binary sort? No idea.
++ > It will be linear in the size of the file. For each addition.
++
++ not always true. depending on how the file is organized. unix has
++ bsearch and friends to find records in a sorted file which is O(log2n).
That's inefficient, as you can find records in O (log n), if you know
how large the records are. But that's irrelevant. The insertion will
take linear time worst case. (Average case too).
++ the berkley database stuff has binary and btree stuff too. all would be
++ faster than sorting each time after adding a record.
++
++ even a simple binary search of a linear file would be much faster than a
++ linear insert. you could find the record location in O(log2n) and then
Of course, a binary search is faster than a linear insert. And a
car is heavier than an apple, but that doesn't make the car a fruit.
++ copy large blocks until the insert point, insert the new record, finish
++ copying with large blocks. you eliminate many of the record compares
++ which is what eats up the cpu.
Rubbish. You got to move a linear number of records. That will dominate
the time spend.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: 10 Mar 1998 19:16:02 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Speed of sort routine vs. one-by-one compare (123)
Message-Id: <x790qiulod.fsf@sysarch.com>
abigail,
you throw around terms like O(logn) like you have taken an algorithm
analysis course but you make several mistakes in your letter.
abigail@fnx.com (Abigail) writes:
> Uri Guttman (uri@sysarch.com) wrote on 1652 September 1993 in
> ++ abigail@fnx.com (Abigail) writes:
> ++
> ++ >
> ++ > What is a binary sort routine?
>
> I know what binary _search_ is, but binary sort? No idea.
it is when you scan all the records into a binary tree O(log2n) and then
scan the tree in infix order giving you a sorted scan. very old and
basic algorithm for O(log2n) sorting.
>
> ++ > It will be linear in the size of the file. For each addition.
> ++
> ++ not always true. depending on how the file is organized. unix has
> ++ bsearch and friends to find records in a sorted file which is O(log2n).
>
> That's inefficient, as you can find records in O (log n), if you know
> how large the records are. But that's irrelevant. The insertion will
> take linear time worst case. (Average case too).
log2n is log(n) base 2 which is the same as log(n) when using order O().
maybe better written log2(n) (it is not log(2n))
all linear factors in O() are not important. only the function of N (the size
of the data set) count.
> ++ even a simple binary search of a linear file would be much faster than a
> ++ linear insert. you could find the record location in O(log2n) and then
> Of course, a binary search is faster than a linear insert. And a
> car is heavier than an apple, but that doesn't make the car a fruit.
oh, really. i have driven lemons :-)
> ++ copy large blocks until the insert point, insert the new record, finish
> ++ copying with large blocks. you eliminate many of the record compares
> ++ which is what eats up the cpu.
> Rubbish. You got to move a linear number of records. That will dominate
> the time spend.
i will double your rubbish back if not satisfied.
in algorithm analysis the comparison is the only thing you count in
O(). I/O is considered fixed linear overhead as ALL algorithms have to
move the same dataset into and out of memory. the fact that it may
dominate real time is IRRELEVANT to the order of the algorithm.
eventually with a large enough dataset a even a log(n) algorithm will be
dominated by the comparisons and not the I/O.
so a binary search of the insert point, with large block I/O will be
FASTER than just a linear search and insert. which is my point.
uri
--
Uri Guttman SYStems ARCHitecture and Software Engineering
uri@sysarch.com Have Perl, Will Hack
http://www.sysarch.com (781) 643-7504 x*2 FAX: (781) 643-2710
Try the Best Search Engine on the Net --------> http://www.northernlight.com
------------------------------
Date: 10 Mar 98 22:24:55 GMT
From: mikeh@minivend.com (Mike Heins)
Subject: Re: The -w switch (was Re: better way to do this?)
Message-Id: <3505bdb7.0@news.one.net>
Useless use of MIME award here. Forget your stupid "V-Card." We aren't
interested.
There is never a reason to post MIME with the only type being
"charset-us-ascii".
Robert Kielty <r.kielty@xtra.co.nz> wrote:
> This is a multi-part message in MIME format.
> --------------E16BF481CE286DADDB6C3D4E
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
> Art Cohen wrote:
>>
> snip
>>
>> : Still no -w and 'use strict'? Do you *enjoy* pain? :)
>>
>> I'd like to say that I almost never use the -w switch and I don't miss it
>> (and I don't particularly enjoy pain).
>>
>> Everybody in this newsgroup posts as if you're a ...
> snip
>> However, if I turn the -w switch on, I get warnings about them! I find
>> this very annoying and not particularly helpful. If I need to initialize a
>> variable, I do it. If I don't need to, I just use the variable name, and
>> Perl works the way it was designed.
>>
>> Does that make me an idiot or a masochist?
> It just means that you can keep a lot of information in your head about
> what
> is going on in your Perl script.
> It also means that you probably know Perl quite well and that you don't
> mind
> taking mental notes of things, where a lot of other programming
> environments
> hold your hand.
> -w is great for people who are used to compiled languages whose
> compilers
> inform them of possible defects in their code.
> The bottom line here is the reduction of time wasted with debugging.
> This implies that you are concerned about saving money.
> If you don't trip up on the more subtle points of Perl then there is
> no need for the -w (or the taint flag, -T I think, for security related
> stuff)
> I view Perl as being a very sharp knife, great at cutting things but you
> gotta know how to use correctly it in order not to hurt yourself badly.
> Rob
> --------------E16BF481CE286DADDB6C3D4E
> Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
> Content-Transfer-Encoding: 7bit
> Content-Description: Card for <b>Robert<b> Kielty
> Content-Disposition: attachment; filename="vcard.vcf"
> begin: vcard
> fn: <b>Robert<b> Kielty
> n: Kielty;<b>Robert<b>
> org: <br><br><img src="http://marketplace.xtra.co.nz/tis.gif" align=left valign=bottom><br>
> adr: 31 Airedale St.;;;Auckland;;;New Zealand
> email;internet: r.kielty@xtra.co.nz
> title: Applications Analyst
> tel;work: + 64 09 3577563
> x-mozilla-cpt: ;1
> x-mozilla-html: FALSE
> version: 2.1
> end: vcard
> --------------E16BF481CE286DADDB6C3D4E--
------------------------------
Date: Tue, 10 Mar 1998 15:54:34 -0600
From: mchunziker@us.fortis.com
Subject: Re: using a scalar in an expression
Message-Id: <6e4coo$5ie$1@nnrp1.dejanews.com>
I would do a chomp($month) just to make sure there are no "\n" (newlines)
at the end of your scaler. I'm new to perl and it's bitten me a few times
already.
In article <35049fd6.30524954@news.f-tech.net>,
farber@f-tech.net wrote:
>
> I'm stumped, im trying to print out a line if it conatians the month,
> the lines in question are:
>
> if ($_ =~ /$month/ )
> { print $_;}
>
> It works fine if I enter /Dec/, it prints out all lines with Dec in
> it, but it willnot work using the scalar, camel book isn't down on my
> level, as I am new to perl.
>
> thanks
>
> Paul
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
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 2067
**************************************