[10470] in Perl-Users-Digest
Perl-Users Digest, Issue: 4062 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 24 17:04:42 1998
Date: Sat, 24 Oct 98 14:00:17 -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, 24 Oct 1998 Volume: 8 Number: 4062
Today's topics:
Re: *Why* does clpm attract non-perl posts? (Tad McClellan)
Email address Checker (Fritz W Feuerbacher)
Re: Email address Checker <egwong@netcom.com>
Re: Email address Checker <flavell@mail.cern.ch>
Re: Javascript in Perl Problem? <mjohnson@getonthe.net>
Re: Newbie help--perl won't run as CGI (Tad McClellan)
Re: Not to start a language war but.. <mhc@Eng.Sun.COM>
Re: Not to start a language war but.. (Cees de Groot)
Re: Not to start a language war but.. (Mike Orr)
Re: Perl & Y2K - booby trap code (Ilya Zakharevich)
Perl scripts under NT, something not right here. <mjohnson@getonthe.net>
Perl under IIS 4.0? <mjohnson@getonthe.net>
Please, how to use C library in perl script... <info@raynette.com>
Re: Problems with plus sign in perl script (David Alan Black)
Re: Problems with plus sign in perl script (Tad McClellan)
Re: Problems with plus sign in perl script <jdf@pobox.com>
Re: programing fun: trees: Part... <xah@best.com>
Re: programing fun: trees: Part... <xah@best.com>
Re: Single word ouptu from aa array <rmcvay@acm.org>
user-friendly date input is computer-friendly (was Re: <Russell_Schulz@locutus.ofB.ORG>
why I feel year-1900 was never a good idea (was Re: Per <Russell_Schulz@locutus.ofB.ORG>
Windows Nt server IIS perl and blat help kmorton424@my-dejanews.com
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 24 Oct 1998 14:09:26 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: *Why* does clpm attract non-perl posts?
Message-Id: <6l8t07.li3.ln@flash.net>
David Alan Black (dblack@pilot.njin.net) wrote:
: "Keith G. Murphy" <keithmur@mindspring.com> writes:
: >Well, when I was in my naive late 30's, instead of the mature and
: >seasoned 40 I find myself at now, I also seemed to think there was some
: >tight coupling between Perl and CGI. There's something about the more
: >general articles and books that are out there that must encourage folks
: >to make that connection stronger than it ought to be. Not that I can
: >cite anything.
(nearly) all CGI programming is done in Perl.
Merely "some" Perl programming is done for the WWW.
Consumers (as opposed to Programmers) know about the WWW, so
the first view is all they have.
Programmers realize that CGI programming is only one application
area in which Perl is used.
Never the twain shall meet...
: One thing is the tendency of bookstores - definitely Borders, and others
: to one degree or another - to shelve all Perl books in the CGI programming
: section. I wonder whether it would be worth campaigning to get this
: changed.
Bookstores cater to Consumers 'cause there are more of them
than Programmers ;-)
: I bow to your age and wisdom (I won't be 40 until Feb. :-)
Spring chickens, both of 'ya ;-(
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 24 Oct 1998 18:14:24 GMT
From: fwf27775@pegasus.cc.ucf.edu (Fritz W Feuerbacher)
Subject: Email address Checker
Message-Id: <70t5e0$mos$1@news.cc.ucf.edu>
Has anyone written a sub function that checks an email address for
vilidity?
--
Linux - The choice of a gnu generation.
------------------------------
Date: Sat, 24 Oct 1998 19:38:39 GMT
From: Eric Wong <egwong@netcom.com>
Subject: Re: Email address Checker
Message-Id: <egwongF1CJwF.LsL@netcom.com>
Fritz W Feuerbacher <fwf27775@pegasus.cc.ucf.edu> wrote:
: Has anyone written a sub function that checks an email address for
: vilidity?
There's te Email::Valid module on CPAN and at
http://olympia2.adhost.com/~maurice/
ERic
[cc'd]
------------------------------
Date: Sat, 24 Oct 1998 21:00:18 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Email address Checker
Message-Id: <Pine.HPP.3.95a.981024205846.23848D-100000@hpplus01.cern.ch>
On 24 Oct 1998, Fritz W Feuerbacher wrote:
> Has anyone written a sub function that checks an email address for
> vilidity?
First you need to define the problem. The FAQ explains the issues,
as I recall.
------------------------------
Date: Sat, 24 Oct 1998 13:54:58 -0500
From: "Matt Johnson" <mjohnson@getonthe.net>
Subject: Re: Javascript in Perl Problem?
Message-Id: <70t7v7$jal$1@news.ipa.net>
Ok, I am definatly not an expert, but I got this tip from someone that is.
Try this code:
#############################
print FILE qq^<script language=\"Javascript\">\n^;
#############################
qq is a double quote that use use a special character to signify the
beginning, and ending of a quote. Using qq will alow you to have the script
interpret special characters such as $,@,#,etc... so that you can insert
parts of perl into your quote. If you dont want Perl to interpret the
special characters just use a single quote. q^STRING^ alows you to put
anything in there and it will quote that whole string and stop with the
delimiter you specity such as ^. The ^ I think can be just about any
character, such as ~, or o, but I am not completely sure on that.
Matt Johnson
cpuweb@cpuweb.com
If I said something wrong someone post a correction PLEASE!
#####################################
END OF REPLY
#####################################
TipTup JHA&HHA wrote in message
<21781-36310BF4-50@newsd-113.bryant.webtv.net>...
alright I'm having a problem with writing Javascript.
print FILE "<script language=\"Javascript\">\n";
print FILE "function name(){\n";
print FILE "alert(\"This is a test\");\n";
print FILE "}\n";
print FILE "</script>";
for some reason this never works, any type of javascript that requires
quotes breaks the perl script...
Any other method to print to a new file (to save) that I can have the
script still work?
Thanks,
Could you please email me the response?
TipTup@webtv.net
------------------------------
Date: Sat, 24 Oct 1998 13:54:30 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Newbie help--perl won't run as CGI
Message-Id: <6p7t07.5f3.ln@flash.net>
David Gibbons (dgibbons@towergroup.com) wrote:
: I am using Windows NT 4 server and IIS 4. I have installed perl, and
: made all ofthe associations, as per the documentation. My perl scripts
: run fine from the command line, but when I try them as a cgi script from
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
So you don't have a Perl problem then.
: a web page, the system just sits there.
: Can anyone help?
For problems with server setup, some newsgroup related to
servers and/or CGI probably has folks that can help:
comp.infosystems.www.servers.ms-windows
comp.infosystems.www.authoring.cgi
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 24 Oct 1998 11:37:15 -0800
From: Mike Coffin <mhc@Eng.Sun.COM>
Subject: Re: Not to start a language war but..
Message-Id: <8p64sstah04.fsf@Eng.Sun.COM>
WMWilson <m.v.wilson@erols.com> writes:
> Just wondering why Perl is so much more popular than python...
Because when you ask questions in the Perl newsgroup you will *not*
get answers peppered with those incredibly annoying <wink>s.
-mike
------------------------------
Date: 24 Oct 1998 21:53:19 +0200
From: cg@bofh.cdg.acriter.nl (Cees de Groot)
Subject: Re: Not to start a language war but..
Message-Id: <70tb7f$vat$1@bofh.cdg.acriter.nl>
WMWilson <m.v.wilson@erols.com> said:
>Just wondering why Perl is so much more popular than python...
Perl was lucky and at two moments in history at the right place in the
right time: first, when it was adapted by Unix system administrators as
a one-size-fits-all language that replaced all the awk, sed, sh, ...
scripts that typically tie a Unix box together. Then, it got a major
boost when somehow the impression was made that Perl==CGI and CGI==Perl
and people started believing that in order to do something more than
serve HTML pages on the Web, you _had_ to learn Perl. This conception
still holds here and there and certainly gave Perl a major boost.
Apart from this, I think that most people who know both languages well
will tell you that Python is intrinsically a better language - easier to
learn, easier to understand, and with a better structured foundation. On
the other hand, Perl has shown the world how to organize extensions:
with CPAN, POD and MakeMaker installing Perl extensions is a no-brainer,
Python is definitely lagging here.
I think the on-line Python manuals (available at www.python.org) are very
usable - start with the tutorial and keep the library reference handy
while programming (btw: I _do_ have a Python manpage on my box). Working
your way through the tutorial will only cost you a few hours and will give
you a very good impression of the language, certainly worth the time.
Re OO programming: read a little more :-). A couple of benefits are that
your code is likely to have a more logical structure (grouped by object
rather than by function), that it is easy to build programs so that old
code can invoke new code, that you can extend old stuff instead of having
to replace it, etcetera.
It was stupid of you to crosspost this - now a language war will certainly
be the result ;-)
--
Cees de Groot http://pobox.com/~cg <cg@pobox.com>
--- We're hiring Java developers => www.acriter.com
------------------------------
Date: 24 Oct 1998 13:41:03 -0700
From: mso@eve.speakeasy.org (Mike Orr)
Subject: Re: Not to start a language war but..
Message-Id: <70te0v$ceq@eve.speakeasy.org>
In comp.lang.python you write:
>Just wondering why Perl is so much more popular than python...I've just
>started learning Perl and have somewhat of an interest in possibly
>giving Python a try as well, just to see which works better for me. It
>doesn't seem like there's as much Python info out there though, I don't
>even have any man pages (that I've found at least) for Python. What's
>the deal? Is it harder, or just newer and hasn't quite been recognized
>yet, or something else? Also, from everything I've read Python is
>object-oriented, I've read a little about object-oriented programming,
>but all in all I haven't really been able to figure out what the big
>deal is, can someone clue me in on this.
RE DOCUMENTATION--
You didn't mention what kind of computer you have, so I don't know how
Python was installed on it. Python's main source of documentation are
the Tutorial, Library Reference and Language Reference. On a Unix
system run "locate tut | grep python | more" to see where
the Tutorial is, or look in /usr/doc/python someplace.
Or download a postscript version from ftp://ftp.python.org/pub/python/docs
(and get FAQ.html while you're at it). Or read the online version at
http://www.python.org/doc/tut/front.html (and browse through the rest
of www.python.org too). You'll see that it's very easy to get started,
especially using interactive mode.
If nothing else, at least type "python" and enter some mathematical
expressions at the ">>>" prompt. For instance, 1024 * 1024 or 2 << 8.
You can use the "_" as a shorthand for "the result of the last
expression". Type Ctrl-D when done. It's a wonderful help when
calculating your roommates' portion of bills, especially since the
previous expressions remain on the screen as a temporary "paper tape"
and you can check your work that way.
For a side-by-side comparision of "How do I do this", see the Perl/Python
Phrasebook at http://starship.skyport.net/~da/jak/cookbook.html.
RE OBJECT-ORIENTED--
The documentation will answer many of your questions. Object-oriented
allows you to create a new data type, not by writing from scratch, but
by merely describing the differences from an existing data type.
Object-oriented allows you to keep the data associated with an object
(e.g., for a CD object, title, artist, song names & lyrics, cover art)
*inside* the object (like C structs), which leads to better organization.
It also allows you to keep an object's methods (functions it knows how
to do, such as play(), list_songs(), self_destruct_if_pirated() )
inside the object. C does not allow this. Perl5 does, but in a very
flexible way which (IMO) allows for many programmer errors, because
the rules are just conventions, rather than being enforced by the parser.
Python has a contrastingly tight way of defining classes and modules,
which makes them less prone to error.
RE PERL (why it's so popular)--
* Perl came out first.
* For years, Perl was the only alternative to sh/sed/awk. Because it
was also free, and because Larry/Tom/Randal did an excellent job of
extolling the benefits of scripting languages, they converted a lot of
people who were previously using sh or C.
* Perl was already mature and widely available in the Unix world when
the Web appeared and thus the need for CGI scripts.
* It has the best regular-expression mechanism on the planet, both in
terms of syntax and performance, which Python has only just begun
to approach in the last release.
* Because Perl's syntax is more flexible (which may be an advantage or
a disadvantage, depending on your philosophy! :), C people feel
immediately at home with its C-like constructs, and sh/awk people
feel comfortable with its sh/awk-like constructs.
RE PYTHON (why it's less popular)--
* Nobody knows it exists. Or if they do, they're afraid to use it because
their boss doesn't see it widely enough used in other places. It took Perl
many years to overcome this hurdle.
* The Pascal-like syntax turns off hard-core C devotees, because it breaks
the rules they're accustomed to (whitespace should be insignificant,
symbols are better than words, blocks should look like
"if(condition) { statement; statement; }" because God (or at least K&R)
said so). Unlike Java, which bent over backwards to retain C constructs
(e.g., the infrequently used do...while loop), Python feels no need to
do things a certain way just because C does.
* The documentation is not quite as well developed. Certain subsystems
(Tk and Curses, for instance) are barely documented at all.
Basically, that's it. It's not an issue of application domain, because
both languages have similar abilities and libraries. Perl evokes the
image of the archetypal hacker sitting at home experimenting, doing it
*his* way, dammit, and nobody better come tell him he should do it
differently. The more $@%{}/* -> => symbols, the better. Who cares
if the result is an unreadable code? Python adherents prefer order and
clearness: they want their work readable by others and see their
piece of code functioning in a larger whole. You get the feeling that
Python programmers are much more likely to use the standard libraries
and make their program conform to them, while Perl programmers are
more likely to write their own libraries if they can, even if a standard
library exists. Thus, IMO, Python is more suitable for large projects
with several programmers working together. Of course, these are huge
overgeneralizations, because both languages can be used either way.
For advocacy and flamewars go to http://www.python.org/search/ and type
"perl" in the "Search the Python Newsgroups" box. There's also a big
set of language comparision pages somwehere, but I forget the URL.
It's on one of the Perl or TCL websites, I think. Use your favorite
search engine.
The best way to see if a language works for you is to code something in
it. The best way to compare languages is to code the same program in
all of them.
--
-Mike Orr, mso@jimpick.com
------------------------------
Date: 24 Oct 1998 18:46:22 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <70t79u$6q1$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Larry Rosler
<lr@hpl.hp.com>],
who wrote in article <MPG.109b91f83063bb279898dc@nntp.hpl.hp.com>:
> Perl is full of little
> "gotchas" (samples on request), of which this is one of the smallest, or
> at least one that has lots of history behind it.
Request.
Ilya
------------------------------
Date: Sat, 24 Oct 1998 01:20:28 -0500
From: "Matt Johnson" <mjohnson@getonthe.net>
Subject: Perl scripts under NT, something not right here.
Message-Id: <70t5uf$igg$1@news.ipa.net>
I just upgraded from IIS 3.0 to IIS 4.0 under NT. I had Perl working fine
under IIS 3.0, but when I upgraded to IIS 4.0 my scripts wont run now. I
even tried reinstalling ActivePerl, but it still doesnt work.
This is the response I get from the server.
##################################
CGI Error
The specified CGI application misbehaved by not returning a complete set of
HTTP headers. The headers it did return are:
Can't open perl script "???????????????????????????": Invalid argument
##################################
This is my simple little script.
##################################
print "Content-type: text/html\n\n";
print "<body bgcolor=\"#FFFFFF\" link=\"#000080\" vlink=\"#000080\">\n";
print "<title>SMA list</title>\n";
open ("file", "+< wo.list");
while (defined($line=<file>)) {
($jobname,$orderdate,$duedate,$address,$phone)=split(/::/,$line);
print $line;
print qq^
<p>
<table border="1" width="100%">
<tr>
<td width="20%">$jobname</td>
<td width="20%">$orderdate</td>
<td width="20%">$duedate</td>
<td width="20%">$address</td>
<td width="20%">$phone</td>
</tr>
</table>
</p>
^;
} # End of while loop.
close ("file");
print "</body>";
#####################################
Now I didn't change anything in my script, and I have looked over some of
the settings in IIS 4.0 but I just dont know enough about it. Do I need to
write the scripts differently for IIS 4.0 to understand them?
If this is not the right place to post this kind of request please let me
know a better place to try. I just want this stupid thing to work.
Matt Johnson
CPUweb Manager
cpuweb@cpuweb.com
------------------------------
Date: Sat, 24 Oct 1998 13:24:14 -0500
From: "Matt Johnson" <mjohnson@getonthe.net>
Subject: Perl under IIS 4.0?
Message-Id: <70t65k$ilb$1@news.ipa.net>
I just upgraded from IIS 3.0 to IIS 4.0 under NT. I had Perl working fine
under IIS 3.0, but when I upgraded to IIS 4.0 my scripts wont run now. I
even tried reinstalling ActivePerl, but it still doesnt work.
This is the response I get from the server.
##################################
CGI Error
The specified CGI application misbehaved by not returning a complete set of
HTTP headers. The headers it did return are:
Can't open perl script "???????????????????????????": Invalid argument
##################################
This is my simple little script.
##################################
print "Content-type: text/html\n\n";
print "<body bgcolor=\"#FFFFFF\" link=\"#000080\" vlink=\"#000080\">\n";
print "<title>SMA list</title>\n";
open ("file", "+< wo.list");
while (defined($line=<file>)) {
($jobname,$orderdate,$duedate,$address,$phone)=split(/::/,$line);
print $line;
print qq^
<p>
<table border="1" width="100%">
<tr>
<td width="20%">$jobname</td>
<td width="20%">$orderdate</td>
<td width="20%">$duedate</td>
<td width="20%">$address</td>
<td width="20%">$phone</td>
</tr>
</table>
</p>
^;
} # End of while loop.
close ("file");
print "</body>";
#####################################
Now I didn't change anything in my script, and I have looked over some of
the settings in IIS 4.0 but I just dont know enough about it. Do I need to
write the scripts differently for IIS 4.0 to understand them?
If this is not the right place to post this kind of request please let me
know a better place to try. I just want this stupid thing to work.
Matt Johnson
CPUweb Manager
cpuweb@cpuweb.com
------------------------------
Date: Sat, 24 Oct 1998 20:42:05 +0100
From: "RAYNETTE" <info@raynette.com>
Subject: Please, how to use C library in perl script...
Message-Id: <70t71v$k21$1@platane.wanadoo.fr>
Hello,
I've searched on dejanews, but did not found the answer ...
I ve got a C library, and i need to call some function in that file from a
perl script. How can i can manage to do that... ?
Is there a c2perl program, or is it about parameters (perl -xxx), or must i
build a module (never done that before) ...
Thanks for your answers.
you would be nice to answer to my email adress too, because i cannot have
acces to this newsgroup very often. THX
info@raynette.com
------------------------------
Date: 24 Oct 1998 14:26:36 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: Problems with plus sign in perl script
Message-Id: <70t64s$afm$1@pilot.njin.net>
jwl@_munged_worldmusic.de (Joergen W. Lang) writes:
>David Alan Black <dblack@pilot.njin.net> wrote:
>> Hello -
>>
>> "Bertil Wennergren" <bertilow@algonet.se> writes:
>>
>> >What's wrong with this script?
>>
>> >#!/usr/bin/perl
>>
>> It doesn't use -w....
>>
>> >$string1 =~ s|$plus_sign|$plus_word|g;
>>
>> + is a special character in regular expressions, so you'd
>> have to escape it in the assignment to $plus_sign.
>Not quite right.
Oy. Thanks for the correction.
David Black
dblack@pilot.njin.net
------------------------------
Date: Sat, 24 Oct 1998 14:02:23 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Problems with plus sign in perl script
Message-Id: <v78t07.5i3.ln@flash.net>
Bertil Wennergren (bertilow@algonet.se) wrote:
: What's wrong with this script?
: #!/usr/bin/perl
You are missing the -w there...
#!/usr/bin/perl -w
: use strict;
You are to be commended for doing the Right Thing with
that pragma there ;-)
: my $plus_sign = "+";
: my $plus_word = "plus";
: my $string1 = "word $plus_sign word";
: print "$string1\n";
: $string1 =~ s|$plus_sign|$plus_word|g;
: print "$string1\n";
: ------------------------------------
: When I run it, I get:
: word + word + word
^^^^^^
If it is really printing that, then you have found a bug in
perl. I can't get it to print that on my system.
I think it is probably really a bug in your article ;-)
: /+/: ?+*{} follows nothing in regexp at test.pl line 12.
: ------------------------------------
: The following works as expected:
[snip]
: $string1 =~ s|\+|$plus_word|g;
You already know that you need to escape the plus sign then.
So just escape the plus sign:
my $plus_sign = "\\+";
or
my $plus_sign = '\+';
or
$string1 =~ s|\Q$plus_sign|$plus_word|g; # see quotemeta() function
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 24 Oct 1998 21:27:25 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: "Bertil Wennergren" <bertilow@hem1.passagen.se>
Subject: Re: Problems with plus sign in perl script
Message-Id: <m367d9so2a.fsf@joshua.panix.com>
"Bertil Wennergren" <bertilow@algonet.se> writes:
> my $plus_sign = "\+";
This is exactly the same as
my $plus_sign = "+";
You'd be better off using "\Q+" or '\+' or "\\+".
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Sat, 24 Oct 1998 11:28:44 +0000
From: "Xah" <xah@best.com>
Subject: Re: programing fun: trees: Part...
Message-Id: <36321af5$0$6383@nntp1.ba.best.com>
Just a Quick note:
Rick Delaney <rick.delaney@shaw.wave.ca> wrote:
>You sure have a lot of these. Are you sure they're not homework? :-)
Homework of the idle. (^_^) I'm currently writing a "partial interpreter" of Mathematica in Perl. That's where these problems came from. Attached below my sig is the description of the module. I hope to put it on CPAN when I'm done.
Long lines in my post or email are intentional. I'll be posting my code tomorrow or comment on Rick Delaney's (if any).
Btw, folks, if you were working on this please finish it and post. It's good to see different codes from different people, especially if different algorithm is used.
Xah, xah@best.com
http://www.best.com/~xah/PageTwo_dir/more.html
Petty penguins make way: GNU HURD is coming! <www.gnu.org>
----------------
=head1 NAME
MathematicaTree - A Perl package for expression structure based functional programing.
=head1 SYNOPSIS
# importing all functions. Recommended.
use MathematicaTree;
# importing a selection of functions.
use MathematicaTree ('functionName1', 'functionName2', ...);
=head1 DESCRIPTION
This package provides about 30 functions for creating and manipulating trees. (tree as nested lists) These functions include tree constructors, selectors, mutators, structure transformers and a set of functions usually found in functional programing languages. Together they form a consistent way of functional programing on trees -- a paradigm often used in Lisp programing. These functions are modeled after the Mathematica language.
This package is written on top of Perl. Speed is not a primary concern, but consistency and high-level expressiveness is. This package is mostly useful in scientific programing.
Perl provides nested lists using references. Familiarity with Perl references is necessary in using this module. See the "See Also" section at the bottom for helpful references.
In this documentation, a tree will mean a nested lists of the form [[...],...]. In other words, when you see "...f(tree) does xxx.", it means the argument to f is a reference to a list. Anything in the tree that is not an array reference is considered an atom. Atoms should be either numbers or strings. Other data types such as hash, tie, typeglob, handle, reference to anything other than array, are not expected.
The following is a list of functions that can be exported, followed by detailed documentation.
=over
=item Tree constructors
Range, Table
=item Tree measurers
Depth, LeafCount, NonleafCount, NodeCount, Dimensions
=item Branchs and Nodes Extractors
Unimplemented: Part, Extract, Level
=item Structure Transformation
Unimplemented: Transpose, Distribute, Thread, Operate, Flatten, FlattenAt, Partition, Sequence, Split.
=item Funtional programming Tools
Function
=item Function on Trees
RotateLeft
Unimplemented: Apply, Map, MapIndexed, MapAll, MapThread, Nest, NestList, FixedPoint, FixedPointList, Fold, FoldList, Outer, Inner, Cross, Union, Intersection, Complement.
=item Tree Index Set Utilities
RandomIndexSet, LeavesIndexSet, NonleavesIndexSet, MinimumIndexSet, CompleteIndexSet, IndexSetSort, TreeToIndexSet, IndexSetToTree
=item Miscellaneous Functions
UniqueString, RandomInteger, RandomReal
=back
------------------------------
Date: Sat, 24 Oct 1998 12:49:10 +0000
From: "Xah" <xah@best.com>
Subject: Re: programing fun: trees: Part...
Message-Id: <36322dce$0$6385@nntp1.ba.best.com>
I think Rick Delaney <rick.delaney@shaw.wave.ca>'s code is elegant enough that probably represents the epitome of recursive approach.
Here's my solution. I haven't done much testing. Also, it doesn't do cyclic indexing, and it can be spruced up... but Rick's speedy and elegant solution ended any enthusiasm to make it perfect before post. Still, post yours if you think it's interesting.
#!/usr/local/bin/perl5 -w
use strict;
use Data::Dumper qw(Dumper); $Data::Dumper::Indent=0;
sub Part ($$@) {
# input checks here...
return _part(@_);
};
sub _part {
if (scalar @_ == 2) {
if (ref $_[1] eq 'ARRAY') {return __part_list(@_);}
else {return $_[0]->[$_[1]];};
}
elsif ((scalar @_) > 2) {
if (ref \$_[1] eq 'SCALAR') {return __part_integer_rest(@_);}
elsif (ref $_[1] eq 'ARRAY') {return __part_list_rest(@_);}
else {print "error: _part: something's wrong in _part\n"; return 0;};
}
else {"error: _part: logical error.\n"; return 0;};
};
sub __part_list {return [map { $_[0]->[$_] } @{$_[1]}];};
sub __part_integer_rest {
my ($ra_tree, $n, @rest) = @_;
return _part( _part($ra_tree, $n), @rest);
};
sub __part_list_rest {
my ($ra_tree, $ra_list, @rest) = @_;
return [map { _part($_, @rest) } @{_part($ra_tree, $ra_list)}]
};
my $tree = [[['000', '001'], ['010', '011']], [['100', '101'], ['110', '111']]];
#print Dumper _part( [5,[98, 43,58],'x'], 3);
#print Dumper _part( [5,[98, 43,58],'x'], 1, [0,1]);
print Dumper _part($tree, 0, [1,0], [1,0]);
---
This code is essentially a direct translation of a Mathematica solution I coded before. The algorithm is essentially same as Rick's. Here's my original Mathematica code for those curious. (*Part* is a build-in function)
Clear[part];
part[expr_,0]:=Head[expr];
part[expr_,a1_Integer]:=First@Take[expr,{a1}];
part[expr_,a1_List]:=(Head@expr)@@(Map[part[expr,#]&,a1]);
part[expr_,a1_Integer,rest___]:=part[part[expr,a1],rest];
part[expr_,a1_List,rest___]:=Map[part[#,rest]&,part[expr,a1]];
Xah, xah@best.com
http://www.best.com/~xah/PageTwo_dir/more.html
Petty penguins make way: GNU HURD is coming! <www.gnu.org>
------------------------------
Date: Sat, 24 Oct 1998 12:55:11 -0500
From: Ray McVay <rmcvay@acm.org>
Subject: Re: Single word ouptu from aa array
Message-Id: <3632147F.EDEE4270@acm.org>
Tad McClellan wrote:
>
> Jakob V. Nielsen (jakob@gemino.no) wrote:
>
> : open (INFILE, "c:\\csv\\cpu_in\\test.txt");
> ^^ ^^ ^^ gak. use single quotes for readability
GAK! Forget the MS BS "c:/csv/cpu_in/test.txt" works fine.
--
Ray
+--------------------------------------------------+
+ I've gone to look for myself. If I should return +
+ before I get back, keep me here!! - Bill the Cat +
+--------------------------------------------------+
------------------------------
Date: Sat, 24 Oct 1998 13:43:25 -0400
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: user-friendly date input is computer-friendly (was Re: Perl & Y2K - booby trap code)
Message-Id: <19981024.134325.6t4.rnr.w164w_-_@locutus.ofB.ORG>
tchrist@mox.perl.com (Tom Christiansen) quotes and writes:
>> There is an unambiguous way that is also *standard*: ISO 8601:1988.
>> The following is the complete long form:
>>
>> yyyy-mm-dd HH:MM:SS (punctuation is optional)
>
> The day that you ask everyone on the street when they were born and
> they all recite an answer in a form such as that is the day that
> computer programmers should expect to use that form as their unique
> input and output style.
output style: no need to wait. do it today.
input style: no need to wait. how many web forms do you see people
asking for the date free-form, when people can remove most of the issue
simply by splitting the input into explicit year and month and day
fields or prompts?
when's the last time any of you filled out a paper form asking for your
birthdate? did it ask for the date in chunks, or just have a big open
area to write it in like you can your address?
if you want to accept two-digit years for conversion to a real date,
it takes only a few bytes to indicate how they will be handled on input
(obviously, some applications will want to deal strictly in the past
[birthdates], some strictly in the future [loans], and most may want to
use dates within 50 years), so there is no ambiguity. and people must
always have the ability to use a real 4-digit year (unless you wish to
ignore those over 100 years old; for how many years have we been reading
about 106 year olds getting mailed notices saying they have to attend
elementary school?).
--
Russell_Schulz@locutus.ofB.ORG Shad 86c
------------------------------
Date: Sat, 24 Oct 1998 13:26:54 -0400
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: why I feel year-1900 was never a good idea (was Re: Perl & Y2K - booby trap code)
Message-Id: <19981024.132654.1S6.rnr.w164w_-_@locutus.ofB.ORG>
[ how about everyone use Followup-To: poster on this for a few days? ]
Jim Brewer <jimbo@soundimages.co.uk> quotes and writes:
>> If someone trips on a banana peel, it's partly their fault for not
>> looking where they were going, but it's also partly the fault of
>> whoever left the banana peel in the way. This is a banana peel.
>
> Only in civil litigation mad America would such a perverted concept be
> uttered.
as I am not in civil litigation mad America, I am a counterexample,
because I agree that
year-1900
is a poor representation for the year, BECAUSE THE CODE FOR HANDLING
IT INCORRECTLY IS MUCH EASIER TO WRITE THAN IT SHOULD HAVE BEEN.
it's not about `fault'. it's about `making it easier to do it right
than it is to do the wrong thing'. or even better, `making it harder
to do something wrong, because people make mistakes even when they're
trying hard not to, and we should try to prevent them as much as
is reasonably possible'.
this is why we have prototypes in ANSI C. this is why automatic
casting between char* and int is obsolete.
we have changed languages so it is harder to make mistakes. once you
endure the pain of transition, the benefit is obvious, and you may wonder
why you ever put up with the errors the older method allowed to pass
without comment.
to use your analogy, this is why we don't build nice sidewalks (with
warning signs) that lead people to walk off a cliff if they're not
paying close attention -- if we build anything there, we build a fence.
people can climb over the fence, but it should be harder than just
walking down the sidewalk.
> Perl has a cliff. Perl has a sign. Read it. Stand back away from the
> edge. Never fall off.
this could only be valid if perl had one `sign'. perl has many `signs'.
you should not have to read (and memorize) every one of them, looking
for the `fine print', to be productive in perl. perl is there to make
programs work sooner, not later.
> Illiterate? Don't program. Can read? RTFM.
the purpose of documenting obscure things is to cause the documenter
to realize:
hey, this is a poor way of doing it. I should go back and fix it.
unfortunately, this did not happen in Unix, C, or perl's localtime();
nor in the dBASE SORT routine that refused to sort a database with
exactly 1 record. it probably took more time to insert the code to
raise that error than it would have to fix the original limitation.
> e-mailed courtesy copies are unappreciated, please refrain.
the new `Mail-Copies-To: nobody' would represent this mechanically.
--
Russell_Schulz@locutus.ofB.ORG Shad 86c
------------------------------
Date: Sat, 24 Oct 1998 18:05:06 GMT
From: kmorton424@my-dejanews.com
Subject: Windows Nt server IIS perl and blat help
Message-Id: <70t4sh$m01$1@nnrp1.dejanews.com>
I was wondering if anybody could help me here:
I am trying to get blat to work under a perl script for Windows NT running
IIS NT server. I can't seem to use blat using exec or system calls in perl. I
get permission denied. I am thinking that the server has permissions turned
off so that I can not run other programs in a perl script. If so, how do you
change that? Is there any test cases I can try?
for example system("blat ...etc") does not return zero but 37686...
I have tried everything but messing with the server. Any help would be
great!
kmorton@bearkan.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 4062
**************************************