[17594] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5014 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Dec 2 03:05:42 2000

Date: Sat, 2 Dec 2000 00:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <975744308-v9-i5014@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 2 Dec 2000     Volume: 9 Number: 5014

Today's topics:
    Re:  basic keys question <juex@my-deja.com>
        ANNOUNCE: Champaign-Urbana Perl Mongers meeting Tue Nov (Daniel S. Lewart)
    Re: DBI question <joe+usenet@sunstarsys.com>
    Re: directing output to the active window <bwalton@rochester.rr.com>
        Does map return a list or an array? <johnlin@chttl.com.tw>
    Re: Does map return a list or an array? (Randal L. Schwartz)
    Re: Does map return a list or an array? (Martien Verbruggen)
    Re: help with regex matching a html document <bwalton@rochester.rr.com>
        How do you compress an entire file with Compress::Zlib mark_ingalls@my-deja.com
        I Have Active Perl--Now What? <mtn_view@sirius.com>
    Re: Loading of modules? <dan@tuatha.sidhe.org>
    Re: Nice Perl 1-liner (Martien Verbruggen)
        one question from newbie <wangwei18@163.net>
    Re: Perl 5 & Perl 6 core files dumps + possible typo in <dan@tuatha.sidhe.org>
    Re: Perl 5 & Perl 6 core files dumps + possible typo in <brian+usenet@smithrenaud.com>
        perl and javascript <alex.thomas@mindspring.com>
    Re: Perl FORMAT Into variable? (Damian Conway)
    Re: PerlIS.dll headers in html <web@web.com>
        Printing to System Que <rhermawan@kafelinux.com>
    Re: Should { } always indicate a scope? <johnlin@chttl.com.tw>
    Re: sockets and threads <dan@tuatha.sidhe.org>
        Sort Question <ned911@home.com>
    Re: Using goto (Shawn Smith)
    Re: Using goto (Shawn Smith)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 1 Dec 2000 20:11:28 -0800
From: "Jürgen Exner" <juex@my-deja.com>
Subject: Re:  basic keys question
Message-Id: <3a287674@news.microsoft.com>

"nougat" <kulabocca69@hotmail.com> wrote in message
news:OzGU5.561$Ei1.32965@bgtnsc05-news.ops.worldnet.att.net...
[...]
> When I do this, the first value assigned to $field_key is "WIN", not
"REG".
> The debugger shows the values of  %fields in the order in which they were
> assigned when initialized. What I'm trying to accomplish is some way to
> initialize the hash so that I can return the keys in a predictable order.
>
> I understand that hashes access key/value pairs randomly, but I have also
> read that the keys operator is supposed to unwind the elements "in order",
> i.e. first key first, etc.
[...]

Hashes do not have an order, in particular they do not keep track of in
which order elements were added. Therefore your request is impossible to
solve.
"Unwinding in order" simply refers to the fact that Perl guarantees that
when unwinding the same hash a second time the elements will be returned in
the same order.

jue




------------------------------

Date: Sun, 26 Nov 2000 07:53:35 GMT
From: d-lewart@uiuc.edu (Daniel S. Lewart)
Subject: ANNOUNCE: Champaign-Urbana Perl Mongers meeting Tue Nov 28
Message-Id: <3k3U5.3788$4h2.66405@vixen.cso.uiuc.edu>

Champaign-Urbana Perl Mongers,

Our next meeting shall be:
	Tue Nov 28 18:00 CST 2000
	Papa Del's
	206 E Green St
	Champaign, IL
Please try to bring at least one question, discussion topic, or script.

Benevolently,
Daniel Lewart
http://cmi.pm.org/


------------------------------

Date: 01 Dec 2000 21:05:44 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: DBI question
Message-Id: <m3zoifr30n.fsf@mumonkan.sunstarsys.com>

Joe Schaefer <joe+usenet@sunstarsys.com> writes:

> my $sth = $dbh->prepart(<<SQL);

OOPS- that's wrong. It should read

my $sth = $dbh->prepare(<<SQL) or die $DBI::errstr;

Sorry about that.

-- 
Joe Schaefer


------------------------------

Date: Sat, 02 Dec 2000 03:21:04 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: directing output to the active window
Message-Id: <3A286B4A.DAA1AA0D@rochester.rr.com>

fredm6816@my-deja.com wrote:
> 
> How can I open an application (i.e. notepad) and be able to type text
> into that application?
> 
> I'm relatively new to Perl, but I do know how to accomplish opening
> applications using the system() command.  I'm more concerned with how
> to direct text output to that window.
 ...
Well, if Notepad were OLE-enabled, you could:

    use Win32::OLE;

to "type" text into the application from your Perl program.  You can do
that, for example, with Microsoft Word.  For how:

    perldoc Win32::OLE;

-- 
Bob Walton


------------------------------

Date: Sat, 2 Dec 2000 13:40:12 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Does map return a list or an array?
Message-Id: <90a24o$mlh@netnews.hinet.net>

Dear all,

Today my collegue asked me "Does map return a list or an array?".
Before I answered, I carefully read the manual.
Hmm... the answer is "a list".  I shouted out loudly "It returns a list."
"Are you sure?"  Then he gave me a quiz.  "Guess what the outputs are."

    sub list { 'A','B','C' }
    print scalar list;

    sub array { my @a = ('A','B','C') }
    print scalar array;

    sub quess { map {$_} 'A','B','C' }
    print scalar quess;

Hmm... The first function returns a list.  So the answer is 'C'.
The second function returns an array.  So the answer is 3.
The third returns a list (according to the document) so the answer is 'C'.

"Buzz... You are wrong... "
After seeing the answer, I think Perl is a little bit too complicated to
learn.
Do you get the correct answer?

John Lin





------------------------------

Date: 01 Dec 2000 21:46:38 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Does map return a list or an array?
Message-Id: <m18zpzxtmp.fsf@halfdome.holdit.com>

>>>>> "John" == John Lin <johnlin@chttl.com.tw> writes:

John> Today my collegue asked me "Does map return a list or an array?".

In what context?

John> Before I answered, I carefully read the manual.

Not carefully enough.

John> After seeing the answer, I think Perl is a little bit too complicated to
John> learn.
John> Do you get the correct answer?

Yes, and so does everyone else that reads the first part of
"perldoc perlfunc" =>

       Remember the following important rule: There is no rule
       that relates the behavior of an expression in list context
       to its behavior in scalar context, or vice versa.  It
       might do two totally different things.  Each operator and
       function decides which sort of value it would be most
       appropriate to return in scalar context.  Some operators
       return the length of the list that would have been
       returned in list context.  Some operators return the first
       value in the list.  Some operators return the last value
       in the list.  Some operators return a count of successful
       operations.  In general, they do what you want, unless you
       want consistency.

       An named array in scalar context is quite different from
       what would at first glance appear to be a list in scalar
       context.  You can't get a list like (1,2,3) into being in
       scalar context, because the compiler knows the context at
       compile time.  It would generate the scalar comma operator
       there, not the list construction version of the comma.
       That means it was never a list to start with.

and then later:

       map BLOCK LIST

       map EXPR,LIST
               Evaluates the BLOCK or EXPR for each element of
               LIST (locally setting $_ to each element) and
               returns the list value composed of the results of
               each such evaluation.  Evaluates BLOCK or EXPR in
               a list context, so each element of LIST may
               produce zero, one, or more elements in the
               returned value.

               In scalar context, returns the total number of
               elements so generated.

RTFM.  It's all there.  Stop blaming Perl for your lack of reading
comprehension. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Sat, 2 Dec 2000 17:25:09 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Does map return a list or an array?
Message-Id: <slrn92h5e4.imr.mgjv@martien.heliotrope.home>

On Sat, 2 Dec 2000 13:40:12 +0800,
	John Lin <johnlin@chttl.com.tw> wrote:
> Dear all,
> 
> Today my collegue asked me "Does map return a list or an array?".
> Before I answered, I carefully read the manual.
> Hmm... the answer is "a list".  I shouted out loudly "It returns a list."
> "Are you sure?"  Then he gave me a quiz.  "Guess what the outputs are."
> 
>     sub list { 'A','B','C' }
>     print scalar list;
> 
>     sub array { my @a = ('A','B','C') }
>     print scalar array;
> 
>     sub quess { map {$_} 'A','B','C' }
>     print scalar quess;
> 
> Hmm... The first function returns a list.  So the answer is 'C'.

A bit of a misconception. A sub never just returns a list or a scalar.
It depends on context only.  A subroutine returns whatever its
context requires.  In a scalar context it returns a scalar, and in a
list context a list. The context in which a sub is placed propagates
into the sub, to the return statement (or the last statement evaluated
in the sub).

The thing you see in the (inappropriately named) sub 'list' is three
scalars separated by the comma operator. The comma operator, in a scalar
context returns its rightmost operand. For the sequence given, that's
'C'.

> The second function returns an array.  So the answer is 3.

No. The second subroutine returns a scalar. The scalar context puts the
array @a in scalar context, and therefore will result in the number of
elements in the array.

> The third returns a list (according to the document) so the answer is 'C'.

No. map in a scalar context returns the number of elements generated, as
documented. So, it will return 3.

> "Buzz... You are wrong... "
> After seeing the answer, I think Perl is a little bit too complicated to
> learn.

It's not too complicated, just misunderstood. One needs to understand
that context, in Perl, is everything, and that a list is not an entity.
It doesn't exist as such. The thing you see with commas between them,
and often brackets around them, is not a list. It's a bunch of scalars
with the comma operator between them. How the various operators and
builtins behave in list or scalar (or void) context is documented, and that
documentation should be consulted to find out what the behaviour is.
Another thing that needs to be understood is that a sub always, always
returns a flat list, and that the context the sub is in propagates into
the sub to the return statement.

> Do you get the correct answer?

Yep.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd.   | you come to the end; then stop.
NSW, Australia                  | 


------------------------------

Date: Sat, 02 Dec 2000 03:14:55 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: help with regex matching a html document
Message-Id: <3A2869DA.18C89BE7@rochester.rr.com>

Joe wrote:
> 
> i have been trying (so hard)to match the document attached with regex
> 
> (the last modified)
> 
> ($title ,$time ,$text) = ($i =~ /[.\n]*?<font
> class=\'btext\'>[(.*)]<\/font>][.\n]*?[<font
> class=\'timetext\'>[(.\n)]*?<\/font>][.\n]*?[<font
> class=\'text\'>[(.\n)]*?<\/td>[.\n]*?/);
> 
> and grabing out some of the contents ,and it doesn't work at all ,while i
> print those var out they seemed to be are undef or empty or something , any
> help or advice would be appreciate
> 
<very voluminous HTML deleted>
Yes, matching HTML is a much more difficult job than most folks think it
is initially.  To do it properly, try:

    use HTML::Parser;

You can learn about it with:

    perldoc HTML::Parser

There may also be other modules out there that will do a similar job.
-- 
Bob Walton


------------------------------

Date: Sat, 02 Dec 2000 05:24:03 GMT
From: mark_ingalls@my-deja.com
Subject: How do you compress an entire file with Compress::Zlib
Message-Id: <90a11h$iku$1@nnrp1.deja.com>

i'm trying to replace a batch file on a windows
nt system that is calling gzip.exe to compress
iis log files for transferring to another machine
with a perl script that does all of the work
internally.

i'm using ActiveSate perl 5.6 build 620 built for
MSWin32-x86-multi-thread.

i've looked at the examples for Compress::Zlib in
the documentation, but they all operate on a
single line or two of input from STDIN.

the files i'm compressing are ~200 MB in size and
i would think passing in a file handle or file
name would be more efficient than reading the
file line by line, compressing each line, then
writing that line back to the compressed file.

i've tried using deflate and compress functions,
but cannot get either to work correctly.  the
compressed files need to be readable by WinZip as
that is the program that my customers will be
using.  i can continue to launch gzip.exe from
the perl script, but i'd like to remove that
dependency if possible.

any help / advice you can offer would be
appreciated.

thanks,
mark


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Fri, 01 Dec 2000 21:22:16 -0800
From: Wayne Watson <mtn_view@sirius.com>
Subject: I Have Active Perl--Now What?
Message-Id: <3A288708.2FC18CF3@sirius.com>

I've used Perl under Unix and decided to download and install Perl under NT. I see that I have a
Start menu entry called Active Perl (AP) with one item in the submenu, Perl Documentation. When I
select it, I see lots of stuff, including Overview, PerlScript, PerlScript Examples. I even found
something called PerlRun. My question is how do I go about creating some simple Perl program and
executing it? Suppose I want to do something as simple as looping from 1 to 5 and printing each
number in the loop?  How do I do that in AP? I also see that I have a Start menu entry for Emacs. If
I'm not mistaken, it wasn't there before.

I downloaded AP 5.22.

--
                              "It's better to wear out than rust out"
                                 -- Theodore Roosevelt, 26th U.S. President

                                            Wayne T. Watson




------------------------------

Date: Sat, 02 Dec 2000 02:36:06 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Loading of modules?
Message-Id: <qeZV5.79350$P82.8445397@news1.rdc1.ct.home.com>

Jason Timmins <jason@webfoundry.co.uk> wrote:
> "Dan Sugalski" <dan@tuatha.sidhe.org> wrote in message
> news:5hRU5.75892$P82.8262174@news1.rdc1.ct.home.com...
>> Jason Timmins <jason@webfoundry.co.uk> wrote:
>> > Hi There,
>>
>> > Can anyone tell me where in the source for Perl 5.6.0 the interpreter
> loads
>> > modules from the file system?
>>
>> > I've found stuff called Perl_load_module but I was looking for a nice
> fread
>> > command.
>>
>> You're not going to find anything nearly that simple, alas. If nothing
> else,
>> the code in a .pm file needs to run through the parser and any executable
>> code needs to be loaded by the OS' shared library loading system.
>>
>> You can check out the require opcode function for a start, and go from
> there.
>> It's got the code to handle loading in perl files from disk. The code to
>> handle loading in shared libraries is in ext/DynaLoader, probably in the
>> dl_dlopen.xs file. (There are a bunch of dl_*.xs files--which one gets
>> used depends on what platform you build perl on, since loading up shared
>> libraries is different on different OSes)
>>
>> I'll warn you, though--it's rather... interesting code.

> Thanks. I'll have a look.

> Do you happen to know if my assumption that the Perl interpreter loads the
> whole .pl in one go and then proceeds to 'run' it, is correct? Or am I
> barking up the wrong tree entirely and it loads lines at a time
> interpreting/translating as it goes?

It sort of is. When the parser is eating a file, if it comes across a
BEGIN block, it stops immediately after it's done parsing it and then
executes the code in the block. When that's done, the parser picks back
up and finishes parsing the file. (It might do this several times, as
it's fine to have multiple BEGIN blocks)

Once perl's done parsing the file it then executes the code in it starting
from the top, and when the code in the file exits, it picks back up doing
whatever it was doing at the time it started parsing the file. Since a
use'd module can use other modules, it's possible perl might have two or three
(or four, or ten...) files partially parsed at any one time.

> Is there an architectural overview of the interpreter on the web? I'm
> interested in understand how it all works.

Well, there's http://gisle.aas.no/perl/illguts/, but that's about it.
Certainly nothing I know of that gets into details on perl's parser. (It
scares folks almost as much as the regex engine, and with good reason... :)

If you come across some, I'd appreciate it if you'd mail the URLs to me.
Might help some folks wrap their brains around what'll need to be done
for perl 6...

					Dan


------------------------------

Date: Sat, 2 Dec 2000 18:47:46 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Nice Perl 1-liner
Message-Id: <slrn92ha92.imr.mgjv@martien.heliotrope.home>

On Fri, 01 Dec 2000 16:49:31 GMT,
	simbean@my-deja.com <simbean@my-deja.com> wrote:
> 
>> shell> perl -e "print grep {(/BEGIN/) .. (/END/)} <>;" file.text
>
> Isn't this a command you could as well issue directly in the linux (or
> unix) shell?
>
> I am not into it, but I'll bet you could get the same output if you put
> that in bash ...

Nope. Noth without the help of sed, or maybe awk.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | I took an IQ test and the results
Commercial Dynamics Pty. Ltd.   | were negative.
NSW, Australia                  | 


------------------------------

Date: Sat, 02 Dec 2000 00:56:10 -0500
From: WEI WANG <wangwei18@163.net>
Subject: one question from newbie
Message-Id: <3A288EF9.B1EBF9ED@163.net>

I want to get time of web server, then use it as start point, to display
a dynamic clock on my homepage. I know how to use javascript to make it
dynamic, but I do not know how to return the server time to javascript.





------------------------------

Date: Sat, 02 Dec 2000 02:41:05 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Perl 5 & Perl 6 core files dumps + possible typo in x2p/a2py.c
Message-Id: <5jZV5.79364$P82.8446530@news1.rdc1.ct.home.com>

Sebastien Blondeel <blondeel@nef.ens.fr> wrote:
> Recently I had the surprise to have Perl5 (and Perl6 compiled to test
> with this new version) dump cores.

Perl 6? Keen! Could you mail me the source? It'll be nice to see the
code we're going to write next year. (Gotta love those
thiotimoline-powered PCs you can get these days... :)

					Dan


------------------------------

Date: Sat, 02 Dec 2000 00:01:46 -0500
From: brian d foy <brian+usenet@smithrenaud.com>
Subject: Re: Perl 5 & Perl 6 core files dumps + possible typo in x2p/a2py.c
Message-Id: <brian+usenet-DB4183.00014602122000@news.panix.com>

In article <5jZV5.79364$P82.8446530@news1.rdc1.ct.home.com>, Dan 
Sugalski <dan@tuatha.sidhe.org> wrote:

> Sebastien Blondeel <blondeel@nef.ens.fr> wrote:
> > Recently I had the surprise to have Perl5 (and Perl6 compiled to test
> > with this new version) dump cores.

> Perl 6? Keen! Could you mail me the source? It'll be nice to see the
> code we're going to write next year.

well, it sounds like it just dumps core. you might want to start
from scratch to fix that. ;)

-- 
brian d foy
Perl Mongers <URL:http://www.perl.org>
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>


------------------------------

Date: Sat, 2 Dec 2000 01:59:46 -0500
From: "Alex Thomas" <alex.thomas@mindspring.com>
Subject: perl and javascript
Message-Id: <90a6oj$hu2$2@slb1.atl.mindspring.net>

is there a way to use perl and JavaScript so that an array created in perl
can be accessed by JavaScript and vice-versa?

-Alex




------------------------------

Date: 2 Dec 2000 03:16:17 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Perl FORMAT Into variable?
Message-Id: <909pi1$v2d$1@towncrier.cc.monash.edu.au>

ryanwol2000@my-deja.com writes:

>Is it possible to create a REPORT or FORMATTED TEXT where the output
>goes into a variable instead of STDOUT? 

It's a pain to do with C<format>.

But if you can live with a slightly different specification syntax,
take a look at Text::Autoformat, specifically Text::Autoformat::form.

Damian


------------------------------

Date: Sat, 02 Dec 2000 07:07:46 GMT
From: "web" <web@web.com>
Subject: Re: PerlIS.dll headers in html
Message-Id: <6d1W5.37780$3u1.9530831@news3.rdc1.on.home.com>

I did and nothing happens
"John Boy Walton" <johngros@Spam.bigpond.net.au> wrote in message
news:ZW0U5.4850$GW5.31191@news-server.bigpond.net.au...
> Try removing the print header line.
>
>




------------------------------

Date: Sat, 02 Dec 2000 12:30:32 -0700
From: Rudy Hermawan <rhermawan@kafelinux.com>
Subject: Printing to System Que
Message-Id: <3A294DD7.CF45A3F1@kafelinux.com>


Greetings,

Pls guide me to print to system queue.

My code is printing directly to the local printer.


=========

open (STDPRT, ">/dev/lp0");

print STDPRT "This will be printed directly to the port.....";

close (STDPRT);

=========

Regards

Rudy Hermawan



------------------------------

Date: Sat, 2 Dec 2000 11:50:07 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: Should { } always indicate a scope?
Message-Id: <909rmb$dsu@netnews.hinet.net>

"Ren Maddox" writes
> "John Lin" writes:
>
> >     my @x = @{ 1,2,3,[4,5,6] };    # exactly the same BLOCK
> >     print @x;
> > syntax error at line 1, near "@{ "
> > Execution aborted due to compilation errors.
>
> I found it interesting that adding parens *inside* the braces "fixes"
> this:
>
>     my @x = @{ (1,2,3,[4,5,6]) };
>     print "@x\n";
> 4 5 6

They are different in meaning, right?  The parenthesis change the commas
from "evaluate, throw away the result and return the right side"
into "list element separator".  What I thought of is a statement, not a
list.
I think the @{BLOCK} is not compiled in the same way as eval {BLOCK} is.
This kind of BLOCK must have been specially treated.

John Lin





------------------------------

Date: Sat, 02 Dec 2000 02:50:30 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: sockets and threads
Message-Id: <WrZV5.79395$P82.8447338@news1.rdc1.ct.home.com>

simbean@my-deja.com wrote:
> Hi all,

> I have the following problem and I try to keep it short:

> I am creating a (few) thread(s) which is listening for a connection
> over a port.
> The thread is detached.
> When I try to close my program, I cannot because the thread is still
> listening for a connection.
> And I cannot close the socket while the thread is listening.
> Is there a way to "remotely" kill that thread?

Nope. Can't do that.

> Or any other ideas?

Well, if you can use non-blocking clals, or calls that have timeouts,
that's best. If you can't, you're reasonably out of luck.

					Dan


------------------------------

Date: Sat, 02 Dec 2000 02:25:50 GMT
From: Ned <ned911@home.com>
Subject: Sort Question
Message-Id: <3A285D90.CA9941DD@home.com>

I am trying to do a descending sort of a flat (text) file.  The sort
below should act on the second field in the file (date) and was working
until today when 12-1-2000 was entered into the file.  It appears the
that the sort is working on the second character in the second field
therefore putting 12-1-200 at the bottom of the list.  The problem is
probably within the ($item) line but I can't find any documention in the
Perl Man/Faq docs to tell what that is doing.  Any help would be
appreciated.

Ned

@idx = ();
   for (@file) {
 ($item) = /\d+\s*(\S+)/;
 push @idx, uc($item);
   }
 @file = @file [sort{$idx[$b] cmp $idx[$a]}0..$#idx];



------------------------------

Date: Sat, 02 Dec 2000 07:15:03 GMT
From: SPAM_loginprompt@yahoo.com (Shawn Smith)
Subject: Re: Using goto
Message-Id: <3a2899f2.10784469@netnews.worldnet.att.net>

On Fri, 1 Dec 2000 08:12:49 -0500, tadmc@metronet.com (Tad McClellan)
wrote:

>Did school include the software life-cycle and where the costs
>of software are apportioned?

I vaguely remember a part of a lecture on that.

>
>>Some of the scripts have goto statements. What I have read is that
>>goto's slow down the scripts because goto's cause Perl to compile the
>>scripts on every run. 
>
>
>Where did you read that? It is a load of errr, stuff.

Can't remember, but maybe I got it confused w/ something else. 

>perl (not Perl) compiles your scripts on every run regardless
>of whether there are gotos or not.

OK. perl is the interpreter, perl is the interpreter, perl is...

>To find out how perl runs, consult the misleadingly named Perl doc:
>
>   perldoc perlrun

From perlrun:
"The special value 00 will cause Perl to slurp files in paragraph
mode. The value 0777 will cause Perl to slurp files whole because
there is no legal character with that value."

Slurp?

>>Also, to justify removing the goto's I must show that it will improve
>                                        ^^^^
>>the efficiency of the scripts. 
>
>
>Doesn't your managment make business decisions based on cost
>versus benefits?

I don't know. I am a peon. I have been there 9 days. From all they
have told me of the infrastructure, I am a bit blurry eyed right now.
They are nice and very open minded. 

>>I can't just say hey these are not cool. 
>
>
>Say:
>
>   "Three quarters of the cost of software over its lifetime is
>    due to maintenance (new features, bug fixes) labor."
>
>   "gotos make code very hard to maintain and modify."
>
>   "If we don't remove the gotos, we will be wasting time
>    (i.e. money) every time we need to change the software."
>
>   "So we could save a lot of money by removing the gotos."
>
>   "Should I go do that for us?"
>
>:-)

Yes. Rereading the camel it said (something like) for maintainability
gotos should be avoided.

Another hurdle is that some of these scripts have functions that are a
dozen pages long. I "think" these should be broken down into smaller
functions.

__

Shawn Smith 
My freeware: http://sites.netscape.net/shawnspad 




------------------------------

Date: Sat, 02 Dec 2000 07:26:25 GMT
From: SPAM_loginprompt@yahoo.com (Shawn Smith)
Subject: Re: Using goto
Message-Id: <3a2aa1d2.12800824@netnews.worldnet.att.net>

On 1 Dec 2000 11:03:12 GMT, abigail@foad.org (Abigail) wrote:


>Perl programs get compiled each time you run it. The fact there are gotos
>in it is irrelevant.

OK.

>If gotos are only used on rare occasions, they can't have much influence
>on efficiency, can they? 

True, and since you say gotos do not slow down a Perl script, then
even if the errors occurred a lot it would not matter.

>To increase the performance, one focusses on
>the bottlenecks, on one some error handling code that isn't called often.

Do you suggest using the profiler?


__

Shawn Smith 
My freeware: http://sites.netscape.net/shawnspad 




------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 5014
**************************************


home help back first fref pref prev next nref lref last post