[8942] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2561 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 11 21:09:40 1998

Date: Mon, 11 May 98 18:01:40 -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           Mon, 11 May 1998     Volume: 8 Number: 2561

Today's topics:
        Reposted cleaned up (hopefully) Re: Reading Code Versus <birgitt@order.booktraders.com>
    Re: Scanning Perl scripts for Y2K problems <merlyn@stonehenge.com>
    Re: Significant digit? <rootbeer@teleport.com>
    Re: Strange behaviour of references... (Martien Verbruggen)
    Re: substitution of text?? (Martien Verbruggen)
        Testing out CGI/Perl scripts on a PC with WIN95 phil@ackltd.demon.co.uk
    Re: Testing out CGI/Perl scripts on a PC with WIN95 <lanier@shell6.ba.best.com>
    Re: Testing out CGI/Perl scripts on a PC with WIN95 <rootbeer@teleport.com>
    Re: UID = 0 (Martien Verbruggen)
    Re: Writing to multiple sockets with select() <rootbeer@teleport.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 11 May 1998 20:02:28 -0400
From: Birgitt Funk <birgitt@order.booktraders.com>
Subject: Reposted cleaned up (hopefully) Re: Reading Code Versus Writing Code, How You learn, was [Re: perl scripts dealing with /etc/passwd]
Message-Id: <35579194.26DC4E03@order.booktraders.com>

{reposted for better readability - cleaning up length of lines]
[last four posts in this thread]

> 
> Allan M. Due <due@murray.fordham.edu> wrote:
> 
> : Your argument for the use of  modules is well made. 
    On the other hand I think it is also important to understand 
    how code is correctly written in order to make informed 
    decisions about the use of modules.  Otherwise you obtain 
    the circumstance that others in this newsgroup are complaining 
    about currently. That users become consumers and not programmers.  
    Modules are a double edged sword  in that sense. They have the 
    potential to encourage people to blindly use tools without 
    understanding them, and without learning how to code correctly 
    in the first place.  Just trying to get it right at
    the beginning so I don't have to go back and unlearn bad habits.
> 
> Eric Bohlman <ebohlman@netcom.com> wrote:
> 
> : Hmm.  All the Perl modules that I've seen over on CPAN 
    come in source form.  That means that if a module has a 
    good reputation, you can actually *read* it to see what 
    correctly-written code looks like.  28 years ago, Gerald 
    Weinberg argued in _The Psychology of Computer Programming_ 
    that reading good code was a very effective, but strangely
> : underrated, way to improve one's own programming skills.  
    More recently, Donald Knuth has talked about "literate 
    programming."
> 
> : Your arguments would make perfect sense if you were 
    talking  about C++ programmers using canned commercial 
    binary-only libraries.  But that isn't the case with 
    Perl programming.
> 
> "Allan M. Due" <due@murray.fordham.edu> wrote:
> 
> : I agree with your points completely, one of the things 
    I like about Perl is the code is always there for you to 
    see.  My point is this.  Folks often post questions asking 
    how do I do X, Then the suggestion is made that a
> : module already does X, in a better way, so go use that 
    module.  A subtle danger is that some will interpret such 
    comments to mean that it is not important to understand the 
    problem, just let the module take care of it as it solves 
    all potential problems.  The modules become a black box.
>   They did not understand the problem in the first place, 
    but now they have a olution, so they never bother to understand 
    the programming issues, and they become blind consumers.   
    Now this would be short sighted of the person using
>   the module but it is an issue.  Which leads to the problem 
    being discussed elsewhere which is that module users start 
    to say things like such and such module doesn't work, fix it 
    for me, rather than looking at the code that is available.  
    Now this is not a major issue but I think it does encourage 
    some folks to not try and solve problems on their own.
> 
> Tom Phoenix wrote:
> 
> > It's not hard to fix this code to follow the specs, but 
    why bother? There are good modules out there, ones which 
    are easy to use, ones which do this for you by using code 
    that's been debugged for your convenience.
> >
> > As my pal Randal says, "Don't try to re-invent the wheel; 
    sometimes you end up with casters." :-)
> 
 I apologize if this is a bit too far off the specific
 discussion regarding using modules as mentioned in the
 above posts, but I was asking myself since a while what the
 right approach is to learn to program:
 
         1. by writing code
            (in the sense that you read about a topic,
            you go through exercises given in books and then
            you test yourself immediately in posting yourself
            a problem, write a little program from the very
            beginning on without having covered at least one 
            third of the material and knowing that all this 
            must be the worst code one can think of and most 
            probably a dangerous one too).
         2. by reading code
            (of which you know it is well written and tested code
            and try to translate it as the main task in the beginning
            and trying to write your own little programs at a much
            later point).
 
 I see the learning process similar to how a child learns to read
 and write or how an adult learns a foreign language.
 
 There are very distinct and heavily discussed and different 
 approaches on how to go from babytalk and 'babywrite' to become a 
 proficient reader and writer in your first and all following 
 languages you learn.
 
 I have my way of thinking about it, but like to hear if others
 think there are analogies which could be drawn for learning a
 programming language and what experienced programmers and teachers
 of programming would think has more weight and effect to a beginning
 learner.
 
 It is often said that if you don't know ANY programming language
 it's different. Same thing if you can't read and write well the
 first language in your life  you can't read and write well any
 foreign language you learn later on.
 
 So if you think the approach should be different dependent on
 knowing already one programming language versus none, I would
 like to know too.
 
 But the main question is what applies when learning the first
 programming language.
 
 Birgitt Funk
 
 P.S. I admit this is a very general questions again, if someone
 likes to respond, may be it would be better to email me.
 I have no feeling for how this post will be judged as
 appropriately being posted here. But your answers would interest
 me a lot. Thanks for your time reading this.


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

Date: Tue, 12 May 1998 00:07:22 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
To: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: Scanning Perl scripts for Y2K problems
Message-Id: <8cwwbs9wtr.fsf@gadget.cscaper.com>

>>>>> "Stuart" == Stuart McDow <smcdow@arlut.utexas.edu> writes:

Stuart> steven.chau@ssmb.com writes:
>> Hi All,
>> 
>> Does anyone know if there is a tool to scan Perl programs for potential year
>> 2000 problems?

Stuart> Scanning for "localtime" might be a good start...

Uh, *why*?

localtime() itself is Y2K.

What are YOU saying?

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 112 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Mon, 11 May 1998 23:43:10 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Yong Huang <yong@shell.com>
Subject: Re: Significant digit?
Message-Id: <Pine.GSO.3.96.980511164241.21974b-100000@user2.teleport.com>

On Mon, 11 May 1998, Yong Huang wrote:

> Did somebody write code to extract significant digits out of a number?

The FAQ talks about this. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 12 May 1998 00:20:00 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Strange behaviour of references...
Message-Id: <6j84jg$s4t$1@comdyn.comdyn.com.au>

In article <xy5iund3q8z.fsf@cream.maths.warwick.ac.uk>,
	Joel Horowitz <horowitz@cream.maths.warwick.ac.uk> writes:
> Hye,
> I don't understand the behaviour of the few lines that follow. Can you
> tell me where I'm missing the point?

There was a thread on here a little ago that talked about this. I
don't remember the particulars, but you can probably find it on
dejanews. it's something like:

() does not create an array, it merely groups things together. You don't
create an array reference by using \(), but by using []. \() will return
a reference to the last element of the comma separated list between
the brackets (scalar context).

In other words: \@array does not do the same as \(list,list); A list
is not an array, even though it can often be treated like one.

> #!/usr/bin/perl -w
> 
> @list=(1..10);
> print ref(\@list)."\n";      # prints ARRAY... OK
> print ref(\(1..10))."\n";    # prints ARRAY... that's what I would expect

The last element between the brackets here is an array

> @list=(1,10);
> print ref(\@list)."\n";      # prints ARRAY... Normal
> print ref(\(1,10))."\n";     # prints SCALAR... Why?

the last element is a scalar.

Try this:

print ref([1,10]), "\n";

> #### Even more surprising:
> print ref(\(1,10..15))."\n";      # prints ARRAY... OK

The last element is an array

> print ref(\(10..15,1))."\n";      # prints SCALAR... Why?

The last element is a scalar

> print ref(\(10..15,1..4))."\n";   # prints ARRAY... OK

The last element is an array.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd.       | negative.
NSW, Australia                      | 


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

Date: 11 May 1998 23:27:32 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: substitution of text??
Message-Id: <6j81h4$rs1$1@comdyn.comdyn.com.au>

In article <7xlns9ov3w.fsf@beavis.vcpc.univie.ac.at>,
	Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at> writes:
> Re: substitution of text??, Andrew <andrew@iaccess.com.au>
> said:
> 
> Andrew> hey, is there a way in perl to substitute a large
> Andrew> number of spaces in a text file with just one space?
> 
>          s/\s+/ /g;

That replaces multiple whitespace characters with a space, not
multiple spaces.

s/ +/ /g;
tr/ / /s;

To do it from the command line:

# perl -pi.bak -e 's/ +/ /g' files_to_process
# perl -pi.bak -e 'tr/ / /s' files_to_process

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd.       | again. Then quit; there's no use being
NSW, Australia                      | a damn fool about it.


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

Date: Mon, 11 May 1998 21:27:06 GMT
From: phil@ackltd.demon.co.uk
Subject: Testing out CGI/Perl scripts on a PC with WIN95
Message-Id: <35576b8c.1231604@news.demon.co.uk>

I am trying to test some web pages which call CGI/Perl Scripts on a PC
and having problems (HTTP 404). I have perl installed on my system and
have tested the scripts in isolation but am not sure that the web
server I'm using knows about it  (I'm using Microsoft Personal Web
Server).

Is the Microsoft Personal Web Server capable of running CGI scripts
and if so, what do I need to do next. If not what server would you 
recommend I use.

Thanks

Phil Taylor


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

Date: Mon, 11 May 1998 16:54:50 -0700
From: "matthew d. p. k. lanier" <lanier@shell6.ba.best.com>
Subject: Re: Testing out CGI/Perl scripts on a PC with WIN95
Message-Id: <Pine.BSF.3.96.980511165256.3327K-100000@shell6.ba.best.com>

phil-

ok, i'll be the one to echo the mantra -

'if the scripts work in isolation, that it's not a perl question', and
this isn't the most appropriate place to ask it.

sorry bout that.

try the cgi groups.

matt lanier
matt@lanier.org
matt@saturn5.com

On Mon, 11 May 1998 phil@ackltd.demon.co.uk wrote:

> I am trying to test some web pages which call CGI/Perl Scripts on a PC
> and having problems (HTTP 404). I have perl installed on my system and
> have tested the scripts in isolation but am not sure that the web
> server I'm using knows about it  (I'm using Microsoft Personal Web
> Server).
> 
> Is the Microsoft Personal Web Server capable of running CGI scripts
> and if so, what do I need to do next. If not what server would you 
> recommend I use.
> 
> Thanks
> 
> Phil Taylor
> 
> 



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

Date: Mon, 11 May 1998 23:54:54 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: phil@ackltd.demon.co.uk
Subject: Re: Testing out CGI/Perl scripts on a PC with WIN95
Message-Id: <Pine.GSO.3.96.980511165330.21974f-100000@user2.teleport.com>

On Mon, 11 May 1998 phil@ackltd.demon.co.uk wrote:

> Is the Microsoft Personal Web Server capable of running CGI scripts

Perhaps you should ask in a newsgroup about that server, or about CGI
scripting. People who like to answer questions about those things tend to
read those newsgroups, and they can give you better and more complete
answers there than we can here. Good luck! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 12 May 1998 00:07:17 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: UID = 0
Message-Id: <6j83rl$s1h$3@comdyn.comdyn.com.au>

In article <35571225.D5ED0226@megacrawler.com>,
	Stephen Hill <stephen@megacrawler.com> writes:
> I am makeing an adduser script which is run through a web based form.
> 
> Is there any way to set the UID to 0 so I can write to the password
> file?

Run the script as root.
Make the script suid

# perldoc perlsec

If you don't have root access on the machine, you can't do it. It
would sort of be silly if you could, wouldn't it?

That said: You should not even THINK about changing passwd files if
you don't know the answer to your own question. There are many many
issues involved, which I won't go into here because they're totally
off topic for this group. Take my advise: Don't do it. Hire someone
who knows how to do this correctly.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | 
Commercial Dynamics Pty. Ltd.       | What's another word for Thesaurus?
NSW, Australia                      | 


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

Date: Mon, 11 May 1998 23:48:04 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Sudarsan Sankar <sudarsan.shankar@citicorp.com>
Subject: Re: Writing to multiple sockets with select()
Message-Id: <Pine.GSO.3.96.980511164457.21974c-100000@user2.teleport.com>

On Mon, 11 May 1998, Sudarsan Sankar wrote:

> Does anyone know why select() system call flags a socket as ready for
> writing even if the listener hasn't executed a read? 

Because you can write to the socket, if the buffer isn't full, without
blocking.

> I am trying to write a server which will send one record at a time from
> an input file to a number of clients.

No problem there...

> I want the server to block on the select() until one of the clients has
> called a read, and then write one record to that client.

Why wait for someone to read? They may not want to read until there's some
data in the buffer. "No, after _you_. I insist!" :-)

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       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 2561
**************************************

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