[12229] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5829 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 29 18:07:18 1999

Date: Sat, 29 May 99 15:00:18 -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           Sat, 29 May 1999     Volume: 8 Number: 5829

Today's topics:
    Re: ActiveState/ActivePerl <jeff@vpervices.com>
    Re: Calling a Perl script <ebohlman@netcom.com>
    Re: Can someone help me on this challenging problem? <uyv_IGNORE_r@hotmail.com>
    Re: Can someone help me on this challenging problem? <uyv_IGNORE_r@hotmail.com>
    Re: Can someone help me on this challenging problem? <larry_br@sea_net.com>
    Re: cont'd <uri@sysarch.com>
        Continued - SQL Tutorial - PERL Alaskan Cruise!  Larry  (FRANK TORRES)
    Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe finsol@ts.co.nz
        Free SQL Tutorial w/ live practice database - for PERL  (FRANK TORRES)
    Re: how to give parameters ? <gellyfish@gellyfish.com>
    Re: Is 'Global symbol "%s" requires...' Fatal? (Ilya Zakharevich)
    Re: killing exec()ed process - how? <otis@my-deja.com>
    Re: Question: Opening and closing files. (Abigail)
    Re: Question: Opening and closing files. <ebohlman@netcom.com>
    Re: Reading Files <ebohlman@netcom.com>
    Re: Recursion with filehandle (Martin Vorlaender)
    Re: Recursion with filehandle <ebohlman@netcom.com>
    Re: Regexp problem confusing me (Jed Parsons)
    Re: Tying a double knot in a hash (Mark-Jason Dominus)
    Re: Using a variable in a hash statement <uri@sysarch.com>
    Re: Using a variable in a hash statement <rick.delaney@home.com>
    Re: Y2K infected Perl code (Ilya Zakharevich)
    Re: Y2K infected Perl code finsol@ts.co.nz
    Re: Y2K infected Perl code <flavell@mail.cern.ch>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 29 May 1999 18:56:07 GMT
From: Jeff Zucker <jeff@vpervices.com>
Subject: Re: ActiveState/ActivePerl
Message-Id: <375037BB.FAF511FC@vpervices.com>

Edmund Paddington wrote:

> I am running windows 95 ... As I understand it, output from any perl script is
> supposed to be routed to the browser, allowing you to test cgi that is
> embedded in HTML documents from within your browser, without having to bother
> your ISP

Yes, you can test perl cgi scripts on your home computer without bothering your
ISP.  But just having perl and a web browser is not enough: you have left out a
step. The browser makes a request to a *web server*; then the *web server*
passes that request to an executable program such as perl; then the *web server*
passes the results of the request back to the browser.

You need to download and install a web server (httpd = hypertext transfer
protocol daemon) that runs on win95 such as apache, xitami, omnihttpd.

Note: you can also test your scripts without either the browser or server.  Use
the DOS console box in windows and run your scripts with "perl -w scriptname" or
by clicking on a script icon.  This will display the text the perl script would
return to the server so you can know if it is sending the right text.  However
if you want to see how that text would be seen by users, you'll need a browser
*and* a server.

--
Jeff.



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

Date: Sat, 29 May 1999 19:48:39 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Calling a Perl script
Message-Id: <ebohlmanFCIF13.Hv2@netcom.com>

MomLucie <momlucie@aol.com> wrote:

: Actually, we have this Perl script working fine at the command line. We would
: like to create a Visual basic interface to it to give more flexibility to the
: user.

Have you considered creating a Tk interface for it?  You can do GUIs in 
pure Perl code now.



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

Date: Sat, 29 May 1999 13:19:22 -0500
From: "Ralph Emerson" <uyv_IGNORE_r@hotmail.com>
Subject: Re: Can someone help me on this challenging problem?
Message-Id: <7ipb60$520@sjx-ixn5.ix.netcom.com>

Thank's for explaining that.  I know it must of been horible to think of
explaining it that way and "Oh no, my dear god you typed it out".  Oh, for
I'm sure many, many others tried to explain it, but failed along the way.
But you, you must be the strongest of them all.  To have the might and
courage to go forth and do such a daring thing such as teach while others
shy from it's uncaring, devil-caressing, cold, clutch.  Why, hundreds of
people total are in these newsgroups.  All intellegent people, yet none of
them could do what you just did in a few words.  Now, I know that they are
all very, very eager to teach + I was eager to learn + Yet none of them
could do what you did.  By that logic, you alone must be the only one that
truly understands this algorithm, and everyone else out there knows it's
name, but nothing about it.

Something more....

Now, to find the path back (like on the 1-2 connection) so I know which
nodes made the path, I would do this.  {tell me if I could be missing
anything}.

>Shortest path from 1->2
>Mark node 1 with '1'
>Mark all unmarked nodes connected to '1's with '2'
>        (that's 3,4,5,8,9)
>Mark all unmarked nodes connected to '2's with '3'
>        (that's 2,6)
>        (finished!)

Find any node marked with a 2 that connect to node 2 {which has a 3}.
Find any node that is marked with a 1 that connects to that node.
Stop at one.

Put those in a stack as I see them, and print out the stack.

Can I just look for any node that has that node's (number-1)?  I haven't
seen anything wrong with that so far.  Also, what do I do if each node has a
distance to the other nodes.  Then, a one node trip could be longer than a 5
node trip.  Would I keep doing your number thing to find all the paths, put
the paths in a list, and output the min of the sums of each of those paths?
Or is there a better way taylor made for that kind of problem?

> Just to give you the idea:
 >The input file looks like this
 >-----------
 >9 {The number of connectors}
>3 4 5 8 9
 >4 8 9
 >1 5 6
 >1 2 8
 >1 3 9
 >3
 >0
 >1 2 4 9
 >5 2 8
 >--------------


>Hope that gives you the idea.  In fact you probably have enough here to do
it.
> Three semesters saved ;)




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

Date: Sat, 29 May 1999 14:21:31 -0500
From: "Ralph Emerson" <uyv_IGNORE_r@hotmail.com>
Subject: Re: Can someone help me on this challenging problem?
Message-Id: <7ipeqm$nor@sjx-ixn6.ix.netcom.com>

>>There are no people in the real world that know programming that are
willing
>>to teach.
>
>Dear Waldo,
>
>You can teach yourself.  Just don't be so lazy.
>


Lazy!  Haven't I mentioned that I have a very large psydo-library of
computer books for just about everything.  I've read each and every one of
them a min of 1 time.  What I have been is patient.  { I'm an invisible
eyeball that has been blindfolded -:)}.  Your explanation was general yes,
but could you give an example much like Quinn?

>Depth first is easy.  Just search the tree in such
>a way that the deepest nodes are searched in
>one branch before searching other branches.
>Breadth first means don't search deep till you
>search part of all the branches.  The only reason
>to ever use breadth first is when there is some
>special bonus in the shallow parts of the branches,
>such as a higher probability of finding what you
>are looking for.  But depth first is conceptually
>simpler and easier to implement.
>
>P.S. I liked your poem, "Concord Hymn."
>
>
P.S.  Thank's.  It was one of my best works.





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

Date: Sat, 29 May 1999 19:46:08 GMT
From: "Larry Brasfield" <larry_br@sea_net.com>
Subject: Re: Can someone help me on this challenging problem?
Message-Id: <4uX33.5610$%U.1059@news.rdc1.wa.home.com>

Followups trimmed to comp.programming .

Ralph Emerson <uyv_IGNORE_r@hotmail.com> wrote in message news:7ipb60$520@sjx-ixn5.ix.netcom.com...
> Thank's for explaining that.  I know it must of been horible to think of
> explaining it that way and "Oh no, my dear god you typed it out".  Oh, for
> I'm sure many, many others tried to explain it, but failed along the way.
> But you, you must be the strongest of them all.  To have the might and
> courage to go forth and do such a daring thing such as teach while others
> shy from it's uncaring, devil-caressing, cold, clutch.  Why, hundreds of
> people total are in these newsgroups.  All intellegent people, yet none of
> them could do what you just did in a few words.  Now, I know that they are
> all very, very eager to teach + I was eager to learn + Yet none of them
> could do what you did.  By that logic, you alone must be the only one that
> truly understands this algorithm, and everyone else out there knows it's
> name, but nothing about it.

That is really getting thick!  Do you honestly
believe what you just wrote?  I hope not.  Try
not to get so carried away with yourself.

There is a simple fact you neglected to feed
into whatever powerful inference machine
led to that barrage.  Usenet fora are not an
appropriate place for long, carefully written,
educational articles on subjects that are
well covered elsewhere.  The articles are
pretty much transient, (notwithstanding the
archives such as Dejanews), and the likely
audience is too small to make such effort
worthwhile, usually.  So your conclusions
about what people know, apparently based
on the idea that if they did know they would
post essays in response to your demands,
are founded on a false premise.

Another fact you might consider:  The effort
that people make here is voluntary.  If you
want people to put out for you, you might
want to avoid insulting nearly everbody.

> Something more....

Please, no!
[major snippage]

--
--
Larry Brasfield
Above opinions may be mine alone.
(Humans may reply at unundered larry_br@sea_net.com )




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

Date: 29 May 1999 16:18:32 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: cont'd
Message-Id: <x7d7zjhbon.fsf@home.sysarch.com>

>>>>> "RJK" == Ronald J Kimball <rjk@linguist.dartmouth.edu> writes:

  RJK> Uri Guttman <uri@sysarch.com> wrote:
  >> look, several people have responded to you and we still don't understand
  >> your problem. you can embed newlines directly in single quoted
  >> strings. you can't interpolate \n into a single quoted string. so what
  >> are you actually trying to do? you show output you want but no data so
  >> how could we divine what you have? 

  RJK> I hate to say this, Uri (no, actually, I don't :) but I understood
  RJK> perfectly the question as asked in the original post.  The poster wants
  RJK> to know the best ways to print newlines in various types of quoted
  RJK> strings.

i politely disagree. he could have been referring to some wacko curses
type thing where he wanted to output some lines after/below others. and
he never said anything about why it had to be single quotes and he never
showed any code (broken or otherwise). so my comments on the muddiness
of the requests is still valid. you interpret them to be newlines in
strings which is a legitimate response but who knows wht he really wants
unless he is clearer about his goals.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 29 May 1999 19:03:25 GMT
From: ftorres@aztec.asu.edu (FRANK TORRES)
Subject: Continued - SQL Tutorial - PERL Alaskan Cruise!  Larry Wall Tom Christiansen
Message-Id: <7ipdlt$gp2$1@news.asu.edu>


I just posted a message about the new FREE SqL Tutorial.  I forgot to mention
that one of my advertisers/sponsors is organizing a PERL Alaskan Cruise!
Speakers include Larry Wall, Tom Christiansen, and 9 other well known 
PERL people.  

You'll see the ad at my site:  http://sqlcourse.com, if you don't see the banner
right away, it's on my other links page.  Just click on the banner or the
link.


Frank Torres
ftorres@sqlcourse.com
http://torresoft.netmegs.com
-- 


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

Date: Sat, 29 May 1999 20:21:49 GMT
From: finsol@ts.co.nz
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <7ipi8u$j5c$1@nnrp1.deja.com>

In article <slrn7kqsao.vm.sitaram@diac.com>,
  sitaram@diac.com (Sitaram Chamarty) wrote:
> On Thu, 27 May 1999 14:36:01 GMT, finsol@ts.co.nz <finsol@ts.co.nz>
wrote:
>
> >Tom, thought you may be interested to know that I'm not the only
> >mis-guided soul using the term "programming language" to describe CGI
> >for expedience.
>
> You may have used it for "expedience" to start with - although I
> doubt that.  But you cannot hide behind that word now, after
> arguing vociferously with everyone here that it *is* indeed a
> language.  A full paragraph is not "expedient" in any way.
>
> Give it up, sister!
>
In the same section of my article I also included CICS, MVS and
Javascript - all of which could be disputed as being a programming
language. For the purposes of the article, in which I tried to avoid as
much jargon as possible, it was convenient to describe them as
programming languages, as programmers use them for
instructing computers i.e. programming. My point was to draw attention
to these languages as having a problem - which they do.  You are only
arguing semantics because you are unable to sucessfully argue against my
main point which is that the Perl programming language is Y2K booby
trapped.

You would do the Perl community more credit by working on Y2K awareness,
not clouding the issue unecessarily.

Jocelyn Amon
--
Financial Solutions Limited
http://www.ts.co.nz/~finsol/


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 29 May 1999 18:59:46 GMT
From: ftorres@aztec.asu.edu (FRANK TORRES)
Subject: Free SQL Tutorial w/ live practice database - for PERL Programmers - Web based
Message-Id: <7ipdf2$goj$1@news.asu.edu>


As a PERL Programmer, I know how necessary it is to know SQL since most
of my apps deal with databases.  For a Free Web-based SQL Tutorial that
features a live practice database where you can practice everything you
learn on-line go to:

http://www.sqlcourse.com

I just registered that name, so if it doesn't make it go to:

http://torresoft.netmegs.com

You will be able to create your own unique tables, perform inserts, updates
deletes, drops, selects, etc.  All on-line too!!

Let me know how it goes.

Frank Torres
ftorres@sqlcourse.com
http://sqlcourse.com
-- 


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

Date: 29 May 1999 18:34:10 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: how to give parameters ?
Message-Id: <7ipbv2$2t6$1@gellyfish.btinternet.com>

On Fri, 28 May 1999 20:29:23 +0200 Man from Earth wrote:
> Hi !
> 
> How can i give the parameters from some script on my server to other script
> on the other server, which ( script ) can get it only in POST method. And
> how to get an answer from that.
> 

You will probably want to be looking at the module LWP::UserAgent part
of the libwww-perl bundle available from CPAN.  It has plentiful
documentation - including a Cookbook , lwpcook, that will give a good
start.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 29 May 1999 18:09:56 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Is 'Global symbol "%s" requires...' Fatal?
Message-Id: <7ipahk$gv1$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Tom Phoenix 
<rootbeer@redcat.com>],
who wrote in article <Pine.GSO.4.02A.9905290901470.4499-100000@user2.teleport.com>:
> >     Global symbol "$no_var" requires explicit package name at (eval 1)
> 
> > Why I cannot catch this error at eval-1?
> 
> For reasons unknown to me, the error message is going through the warn
> mechanism rather than being trappable by the eval. Could be a bug in Perl.

Would you prefer to see only one syntax error per compilation?

Ilya


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

Date: Sat, 29 May 1999 19:44:21 GMT
From: Otis Gospodnetic <otis@my-deja.com>
Subject: Re: killing exec()ed process - how?
Message-Id: <7ipg2l$hn7$1@nnrp1.deja.com>

In article <slrn7kukhe.n0.efflandt@efflandt.xnet.com>,
  efflandt@xnet.com wrote:
> On Fri, 28 May 1999 04:12:24 GMT, Otis Gospodnetic <otis@my-deja.com>
wrote:
> >Hello,
> >
> >I was wondering if it is possible to get the PID of a 'command'
executed
> >by exec() so that the 'command' can be killed directly (killing the
> >process that called the exec() doesn't kill the 'command' - the
> >'command' keeps running)
>
> Perhaps misunderstand exec() and should read 'perldoc -f exec'.
Nothing
> is returned from exec() unless it fails.  So as soon as a script (or
fork)
> does an exec(), that script (or fork) is terminated and only the
exec'd
> command remains (it has no parent).

In my particular case a script forks X processes, each of which does
exec(), so even though forked processes are gone right after exec() the
main script process still exists (see below)

> >In particular, my script forks a few processes and each of those
> >processes does exec("command")
> >Later, I need to kill everything: my script, all forked processes, as
> >well as all commands that were exec()ed.
>
> The forks are already dead as soon as they exec(), so there is no
> relation between the original script and the commands exec'd from the
> forks.

But there is between my main script and the forked processes (I keep
track of what I forked).

> >In code:
> >unless ($childPID = fork)
> >{
> >    exec ("sleep 30");
> >}
> >wait;
>
> Just curious why you are forking and exec'ing a shell command, when
that
> whole routine could likely be replaced with the simple perl command:
>
> sleep 30;

This was just an example. My application is a little bit more complex :)

> >While this code is running I need to be able to kill it, as well as
the
> >forked process and the 'sleep 30' command that the formed process
> >called.
> >Is this possible?
>
> Yes, if you use system() or backticks instead of exec().

I believe I cannot use system() because I need X processes forked. Or
maybe I could use system since I fork before exec().
Backticks I haven't tried yet in this application.

Otis


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 29 May 1999 16:07:28 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Question: Opening and closing files.
Message-Id: <slrn7l0m5s.7ub.abigail@alexandra.delanet.com>

Tony Bowden (tony@blackstar.co.uk) wrote on MMLXVII September MCMXCIII in
<URL:news:7g9k5d$732$1@nclient3-gui.server.ntli.net>:
|| Abigail <abigail@fnx.com> wrote:
|| > David Cassell (cassell@mail.cor.epa.gov) wrote on MMLXII September
|| > MCMXCIII in <URL:news:37210A44.47C2D26A@mail.cor.epa.gov>:
|| 
|| The 2562nd of September 1993?


Uhm, yes. Is something wrong with that?



Abigail
-- 
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Sat, 29 May 1999 21:51:40 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Question: Opening and closing files.
Message-Id: <ebohlmanFCIKq5.71@netcom.com>

Abigail <abigail@delanet.com> wrote:
: Tony Bowden (tony@blackstar.co.uk) wrote on MMLXVII September MCMXCIII in
: <URL:news:7g9k5d$732$1@nclient3-gui.server.ntli.net>:
: || Abigail <abigail@fnx.com> wrote:
: || > David Cassell (cassell@mail.cor.epa.gov) wrote on MMLXII September
: || > MCMXCIII in <URL:news:37210A44.47C2D26A@mail.cor.epa.gov>:
: || 
: || The 2562nd of September 1993?


: Uhm, yes. Is something wrong with that?

For the benefit of those who aren't in on the joke:

In 1993, AOL made a Usenet gateway available to their subscribers.  They 
implemented the interface to the gateway in such a way that the 
newsgroups looked to their subscribers just like AOL's internal forums, 
with no indication that they were pre-existing fora with established 
cultures of their own.

The result of this was that Usenet experienced a flood of newbies similar 
to what used to happen in September when new college freshmen would gain 
access to it for the first time.  Except this time, the flood never 
slowed down as Internet access continued to be mass-marketed.  Thus, it's 
been said that it's been perpetual September on Usenet ever since 1993.

<philosophizing>
The common explanation for the deterioration of the quality of Usenet 
discourse since then is that the ability to post to Usenet without having 
to understand the syntax of a program known as sh on an operating system 
known as Unix lowered the IQ level needed to post on Usenet.  IMHO, this 
is bogus; a look at rec.org.mensa will show very little correlation 
between the type of abilities measured by tests like the WAIS and the 
quality of people's posts.

My take on the phenomenon is that in the past, newbies were always a 
minority of Usenet users at any given time.  Therefore, they were easy 
socialized into the existing culture of Usenet because the vast majority 
of behavioral cues they were exposed to came from experienced Usenet 
participants.  What happened with mass-market access was that suddenly 
the newbies vastly outnumbered the oldbies and started taking cues from 
each other rather than from people who already knew something about the 
culture.  As a result, they came up with "new" modes of online behavior 
that any veteran could tell you wouldn't work from experience.  Thus the 
problem wasn't that mass-marketing lowered the *quality* of participants, 
but rather increased the *quantity* of participants faster than they 
could be socialized.

I realize quite a few people will object to this explanation, but IMHO 
the majority of the problems coming from mass-market access represent a 
deterioration of *social* skills, not *technical* skills (and, IMHO, the 
"Usenet should be a help desk" syndrome reflects faulty enculturation 
rather than technical incompetence.  c.l.p.misc gets hit especially hard 
by this because the association of Perl with CGI combined with the glut 
of "Web designers" to produce an army of people who wanted to do 
programming without becoming programmers).
</philosophizing>




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

Date: Sat, 29 May 1999 20:24:38 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Reading Files
Message-Id: <ebohlmanFCIGp2.JJK@netcom.com>

Frank Hale <frankhale@yahoo.com> wrote:
: I would like to read a file into an array and split it on a semi-colon. 

Others have pointed out how you need to do this, but I just need to point 
one thing out:

: 	s/^\s+//g;    # Strip trailing whitespace

You *really* need to watch out for errors like this.  A misleading 
comment is worse than no comment at all; it can turn debugging into 
absolute hell because your mind will believe the comment over the code 
being commented.



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

Date: Sat, 29 May 1999 18:04:02 +0200
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Recursion with filehandle
Message-Id: <37500ff2.524144494f47414741@radiogaga.harz.de>

Hugh Denman (hd213@nospam.cam.ac.uk) wrote:
: I'm trying to write a script to remove brackets from all filenames in
: a directory tree. The script below only recurses the first directory
: entry, even though the @dirs array does contain all the
: subdirectories. Can anyone help please?
:
: sub fixdir
: {
:    my @entries,@files,@dirs;
:    my $dirname=shift; 
     local(*DIR);
:    if (opendir(DIR, $dirname))

cu,
  Martin
--
                        | Martin Vorlaender | VMS & WNT programmer
 VMS is today what      | work: mv@pdv-systeme.de
 Microsoft wants        |       http://www.pdv-systeme.de/users/martinv/
 Windows NT 8.0 to be!  | home: martin@radiogaga.harz.de


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

Date: Sat, 29 May 1999 20:18:24 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Recursion with filehandle
Message-Id: <ebohlmanFCIGEp.JC4@netcom.com>

Hugh Denman <hd213@nospam.cam.ac.uk> wrote:
: sub fixdir
: {
:    my @entries,@files,@dirs;

While you probably think that you just localized three arrays, you
actually localized only @entries.  What you've got here is a
comma-separated list of three expressions, one of which has the side
effect of localizing @entries.  As a result, @files and @dirs are *global*
variables and consequently they're getting trashed during the recursion. 
"use strict;"  would have given you a warning about this. 

To localize a list of variables, you need to write them in a list:

my (@entries,@files,@dirs);

But as at least one other person has pointed out, you should be using 
File::Find rather than reinventing the wheel.


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

Date: 29 May 1999 19:45:58 GMT
From: jed@socrates.berkeley.edu (Jed Parsons)
Subject: Re: Regexp problem confusing me
Message-Id: <7ipg5m$h1a$1@agate.berkeley.edu>

Argh.  Of course.  I had only tried to see if there were whitespace
characters hiding in there.  It turns out most of the important lines
have three or more nulls prefixed to them.

Thanks for helping me solve something I should have been able to do
on my own.  :-)

Cheers,

Jed

-- 
Jed Parsons            http://www.ocf.berkeley.edu/~jparsons/
(Jed's another Plautus hack?)       jed@socrates.berkeley.edu
-------------------------------------------------------------
grep(do{for(ord){$S+=$_&7;grep(vec($s,+$S++,1)=1,5..$_>>3)}},


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

Date: Sat, 29 May 1999 18:13:42 GMT
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Tying a double knot in a hash
Message-Id: <7ipaot$ie9$1@monet.op.net>

In article <374EAEAA.D46D71DA@lucent.com>,
Burton Kent  <burton.not.spam@lucent.com> wrote:
>The double knot occurs because I'm also tying
>a SDBM_database to the anonymous hash returned
>by TIEHASH.

It's hard to believe that you mean what you say here, but if you do
mean it, then what you are doing is an incredibly bad idea and it is
definitely not going to accomplish anything useful.


>What can I try?  Is this a bug?

I don't understand what you're trying to accomplish or how you're
trying to accomplish it.  You need to make a more complete statement
of what you want to do, and then show a more complete version of the
code that you are using to do it.  You said you were doing two ties,
but you only showed us one:

>#dbmopen(%hash, $DATABASE, 0700) ||  #interchangable with below
>tie (%hash, 'SDBM_File', "$DATABASE", O_RDWR|O_CREAT, 0700) || #interchangable
>with above
>        die "Could not open database $DATABASE\n";


>Can't use string ("HASH(0x175064)") as a HASH ref while "strict refs"
>in use at remap line 207, <INPUT> chunk 1.
>



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

Date: 29 May 1999 16:35:19 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Using a variable in a hash statement
Message-Id: <x790a7hawo.fsf@home.sysarch.com>

>>>>> "RD" == Rick Delaney <rick.delaney@home.com> writes:

  RD> [posted & mailed]
  RD> Matthew Amster-Burton wrote:
  >> 
  >> There's also no need to make an array and then a hash to hold the same
  >> data.  Rewrite your loop something like this:
  >> 
  >> %h = ('1', 'Red', '2', "Blue", '3', 'Green', '4', 'Yellow');

note to original poster: why is blue quoted differently than the others?


  >> while( my( $num, $color ) = each %h ) {
  >> print "$num  $color\n";
  >> }

  RD> There is no guarantee that this will come out in numeric order.

  RD> perldoc -f each

  RD> If you want it sorted by keys then sort the keys.

  RD>     for my $num (sort {$a <=> $b} keys %h) {

we know the numbers are from 1 to 4 ( or scalar keys %h) so do that as:

	for my $num ( 1 .. keys %h ) {

  RD>         print "$num  $h{$num}\n";
  RD>     }

actually since this is a simple array lookup whyuse hashes at all?

@colors = qw( Red Blue Green Yellow ) ;

$num = 0 ;
foreach $color ( @colors ) {
	print "$num	$color\n" ;
}

chomp( $favorite = <STDIN> ) ;		# spelled american style!

if ( 1 <= $favorite && $favorite <= @colors ) {

	print "your favorite color is $colors[$favorite - 1]\n" ;
}
else {

	print "you don't have a favorite color, dweeb!!\n" ;
}

i like hash slices. so try this version:

@colors = qw( Red Blue Green Yellow ) ;
@num_to_color{ 1 .. @colors } = @colors ;

	foreach $num ( 1 .. keys %h ) {

		print "$num  $num_to_color{$num}\n";
	}

chomp( $favorite = <STDIN> ) ;		# spelled american style!

$color = $num_to_color{$favorite}\n" ;

if ( $color ) {

	print "your favorite color is $color\n" ;
}
else {

	print "you don't have a favorite color, dweeb!!\n" ;
}


hth,

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Sat, 29 May 1999 21:22:30 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Using a variable in a hash statement
Message-Id: <37505A4F.C6536A2C@home.com>

[posted & mailed]

Uri Guttman wrote:
> 
> actually since this is a simple array lookup whyuse hashes at all?

Ain't Usenet wonderful?  Just this morning you replied to a post of mine
stating that you'd already said the same thing.

I hadn't seen it.  I guess you haven't seen my post that says the same
as above.  :-)

> @colors = qw( Red Blue Green Yellow ) ;
> 
> $num = 0 ;
> foreach $color ( @colors ) {
>         print "$num     $color\n" ;
> }
> 
> chomp( $favorite = <STDIN> ) ;          # spelled american style!

Maybe you could use the typing-time saved by your frugal language to
test the code you bothered to type.  :-)  This prints

0     Red
0     Blue
0     Green
0     Yellow

The original poster actually created the menu this way, except he got it
right.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: 29 May 1999 18:14:29 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Y2K infected Perl code
Message-Id: <7ipaq5$h1a$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Jonathan Stowe 
<gellyfish@gellyfish.com>],
who wrote in article <7iopen$2i2$1@gellyfish.btinternet.com>:
> >> I thought that DWIMming was based on syntactic analysis.  Applying it to 
> >> the contents of string literals takes it to new heights (depths?).
> >> 
> >>    s?printf '...19%d...', ..., $year, ...;
> >> 
> >> will be next, I presume?
> > 
> > This is not "next".  This is exactly what the next version of Perl may
> > detect (given that $year comes from localtime()).
> > 
> 
> Awesome.  Does this mean that perl will keep track of the source of the
> value of each variable in order to prevent possible mis-use of that value?

Each value?  Why?  Just mark a year returned from localtime() by
attaching a MAGIC.  (But this is not how the currently available patch
is implemented - this were just my old only-20%-serious suggestions.
But people actually *started to implement* these ideas.)

> Unless I miss something that means that the concept of variable will be
> expanded to keep track of whatever the RHS of an assigment was.  But
> how can that work to include any lvalue such as substr() ?

I have no idea what you are talking about in these sentences.

Ilya


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

Date: Sat, 29 May 1999 20:04:12 GMT
From: finsol@ts.co.nz
Subject: Re: Y2K infected Perl code
Message-Id: <7iph7s$iej$1@nnrp1.deja.com>

In article <slrn7kt1us.1d8.M.Ray@carlova.ulcc.ac.uk>,
  M.Ray@ulcc.ac.uk (Malcolm Ray) wrote:
>
> Programming should not be done by guesswork.

Yes, we all have opinions on how programming should be done and who
should be doing it.  But thats not going to solve the immediate problem
of existing code thats wrongly programmed. Is that not more of a concern
right now? What have you and other Perl developers done about that? Will
all Perl Y2K problems that occur be non-critical? Does the Perl
community take no responsibility in ensuring that Perl developers get
the message that there is a need to check Perl code for Y2K problems?
Particularly if there is the chance that they have not fully understood
the usage of localtime.

Jocelyn Amon
--
Financial Solutions Limited
http://www.ts.co.nz/~finsol/


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Sat, 29 May 1999 23:25:01 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Y2K infected Perl code
Message-Id: <Pine.HPP.3.95a.990529231656.4249D-100000@hpplus01.cern.ch>

On Sat, 29 May 1999 finsol@ts.co.nz wrote:

> Yes, we all have opinions on how programming should be done and who
> should be doing it.  But thats not going to solve the immediate problem
> of existing code thats wrongly programmed.

You seem to be wanting to ignore what the programmer specified, and
guess what they wanted instead.  Excuse me, but I think this kind of
approach is ultimately doomed.  If the specification is wrong, then
change the specification, don't just ignore it.  In this case, the
specification is very simple and clear.  I'm well aware that some have
preferred to ignore it, but I don't accept that ignoring the
specification and guessing what they really wanted is any kind of
solution. 

> Does the Perl
> community take no responsibility in ensuring that Perl developers get
> the message that there is a need to check Perl code for Y2K problems?
> Particularly if there is the chance that they have not fully understood
> the usage of localtime.

Perl has no Y2K problems.  That is clearly documented.

The Perl community took responsibility for making comprehensive
documentation available.  I take my hat off to them (or would, if I wore
one).  Those who preferred superstition over reading the documentation,
and thereby created Y2K problems where there were no Y2K problems, must
accept the responsibility for what they did. 



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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

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

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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


------------------------------
End of Perl-Users Digest V8 Issue 5829
**************************************

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