[23762] in Perl-Users-Digest
Perl-Users Digest, Issue: 5966 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Dec 21 06:08:13 2003
Date: Sun, 21 Dec 2003 03:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 21 Dec 2003 Volume: 10 Number: 5966
Today's topics:
Re: [HELP] code modification <matthew.garrish@sympatico.ca>
Re: [HELP] code modification <1usa@llenroc.ude>
Best Excel Processor <test@test.com>
Re: creating a table report <tarvin@vnet.net>
Re: how do I send emails as html? <nospam@bigpond.com>
Re: how to read data from EXCEL <matthew.garrish@sympatico.ca>
HTTP_CONNECTION = Keep-Alive or 180 seconds <test@test.com>
Re: Is mysql.pm part of DBI? <test@test.com>
Re: Is mysql.pm part of DBI? <spamfilter@dot-app.org>
Re: Is Tie::CSV_File dependable on Tie:File <test@test.com>
Re: Is Tie::CSV_File dependable on Tie:File <1usa@llenroc.ude>
Re: Is Tie::CSV_File dependable on Tie:File <syscjm@gwu.edu>
Re: Ordering arrays? <shondell@cis.ohio-state.edu>
Parsing File (BrokenSaint)
Re: Please critique this short script that scans a log <uri@stemsystems.com>
Re: Please critique this short script that scans a log <syscjm@gwu.edu>
Re: replacing two EOL chars by one (Tad McClellan)
Re: replacing two EOL chars by one <gregm-news@toadmail.com>
Re: replacing two EOL chars by one <spam@thalassa.informatimago.com>
Re: replacing two EOL chars by one <tov@eecs.harvREMOVEard.edu>
Re: replacing two EOL chars by one <tov@eecs.harvREMOVEard.edu>
Re: replacing two EOL chars by one (Xah Lee)
Re: sum of numbers (Rasto Levrinc)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 21 Dec 2003 01:46:45 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: [HELP] code modification
Message-Id: <flbFb.27280$CK3.3141182@news20.bellglobal.com>
"Paul Sellis" <paul.sellis@alussinan.org> wrote in message
news:paul.sellis-D661C5.18472220122003@news3-1.free.fr...
> In article (Dans l'article)
>
> So for my Flash form submission with CGI, you recommanded me 2 scripts
> - FormMail
> - TFMail
>
As it says on the site:
TFMail - Improved Form Mail
If you can't modify it to meet your needs, you're going to have to learn
some Perl. This is a technical newsgroup, not a place to get your scripts
customized for you.
Matt
------------------------------
Date: 21 Dec 2003 07:16:43 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: [HELP] code modification
Message-Id: <Xns9458172E65140asu1cornelledu@132.236.56.8>
Paul Sellis <paul.sellis@alussinan.org> wrote in
news:paul.sellis-D24BF0.16561920122003@news1-1.free.fr:
> I paste here the code in case of you want to look at it :
> (I don't remember if that's bad or not to put the whole code Š I hope
> notŠ)
Well, frankly, I find this whole thread annoying, but apart from that, do
read the copyright and licensing statements found in programs you use:
> # Selling or distributing this program without prior written approval
> # is forbidden.
While you are not selling, you have indeed distributed the program by
posting it on the UseNet. I assume you had already secured said written
approval before posting the program.
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: Sun, 21 Dec 2003 03:19:21 GMT
From: "I Report, You Decide" <test@test.com>
Subject: Best Excel Processor
Message-Id: <Zi8Fb.221725$Ec1.7914917@bgtnsc05-news.ops.worldnet.att.net>
Spreadsheet::TieExcel
URL
http://search.cpan.org/~scesano/Spreadsheet-TieExcel-0.7/TieExcel.pod
That is the best one I have ever seen. It can help me master a table.
It is pretty new, because it is release on Nov 30, 2003.
--
I am Social Liberal-Fiscal Conservative
Social Liberal: Forgiveness, Acceptance of Difference, Universal Healthcare,
Free College Education for Everyone
Fiscal Conservative: Small Government, No Tax for Low Income
------------------------------
Date: Sat, 20 Dec 2003 20:50:18 -0500
From: "tarvin" <tarvin@vnet.net>
Subject: Re: creating a table report
Message-Id: <Nradne3Q2qqnYXmiRVn-iQ@ctc.net>
You could create a pdf (using text2pdf) if you want to lock down the
formatting.
"Ravi Krishna" <rkdba@sympatico.ca> wrote in message
news:9fBEb.20503$CK3.1961974@news20.bellglobal.com...
> I am using Perl DBI to generate a report like this which is then mailed to
specific users.
>
> WEEKLY REPORT FROM 08-Dec-2003 TO 14-Dec-2003
>
+---------------------------------------------------------------------------
-----------------+
> |Client |Srches |GS Src|GS BK |GS BK |Total BK|Total BK |Total
Tkt|Total Tkt|B/S |T/S |
> | | | | |Value($)| |Value($) |
|Value($) | (%) |(%) |
>
+---------------------------------------------------------------------------
-----------------+
> |aaa |17651 |3159 |68 |82,774 |508 |681,638 | |
| 2.88| |
> |bbb |11106 | | | |15 |17,321 |9
|9,796 | 0.14| 0.08|
>
+---------+-------+------+------+--------+--------+----------+---------+----
-----+-----+-----+
>
> I use standard format and write command to generate the above report.
>
> While this serves the purpose adequately, it has limitations.
>
> (a) The mail reader like Outlook must see the mail in plain text form
(courier new font).
>
> (b) If I have to add more columns it becomes ugly.
>
> Is there an easy way to include font specifications in the report so that
the mail reader
> automatically reads this as courier new. Also if I add more columns, will
the report just
> extend its width automatically or will it wrap around to the next line.
>
> How about using some other method to generate a tabular report. Any ideas?
>
> TIA.
>
>
------------------------------
Date: Sun, 21 Dec 2003 09:17:29 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: how do I send emails as html?
Message-Id: <15342144.LYvDM7TAPq@gregs-web-hosting-and-pickle-farming>
It was a dark and stormy night, and Julia Briggs managed to scribble:
> What headers/data do I have to add to output sent emails as HTML?
>
> Any advice or examples?
#!/usr/bin/perl
use strict;
require MIME::Lite;
require MIME::Lite::HTML;
my $msg;
$msg = MIME::Lite->new(
To =>'gmtoomey@no-spam-please.com',
From =>'newsletter@spam-me-please.com',
Subject =>'HTML with in-line images!',
Type =>'multipart/related'
);
$msg->attach(Type => 'text/html',
Data => qq{ <body>
Here's <i>my</i> image:
<img src="http://spam-me-please.com/images/spam.gif">
</body> }
);
$msg->send;
gtoomey
------------------------------
Date: Sun, 21 Dec 2003 02:19:00 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: how to read data from EXCEL
Message-Id: <uPbFb.27314$CK3.3154635@news20.bellglobal.com>
<attribution corrected>
"Carlo Cazzaniga" <carlo.runner@libero.it> wrote in message
news:qN%Eb.199077$vO5.7936081@twister1.libero.it...
> "Fengshui" <test@test.com> ha scritto nel messaggio
> news:vIRCb.451818$0v4.20914757@bgtnsc04-news.ops.worldnet.att.net...
> > I would like to know if excel file is a BINARY or TEXT file. I konw .csv
> is
> > text file.
> >
> It's TEXT file..
>
Funny, I thought excel files used the Binary Interchange File Format...
Matt
------------------------------
Date: Sun, 21 Dec 2003 07:31:58 GMT
From: "I Report, You Decide" <test@test.com>
Subject: HTTP_CONNECTION = Keep-Alive or 180 seconds
Message-Id: <O%bFb.222390$Ec1.7936573@bgtnsc05-news.ops.worldnet.att.net>
Need to run a client side script to call something on a web server
Want to know if the http header
HTTP_CONNECTION = Keep-Alive
is sent from the client or set by the server
I have heard if the transfer of data is not finished in 180 seconds, the
server will stop sending data, then I guess download will never be
completed.
------------------------------
Date: Sun, 21 Dec 2003 08:51:27 GMT
From: "I Report, You Decide" <test@test.com>
Subject: Re: Is mysql.pm part of DBI?
Message-Id: <jadFb.504357$0v4.21746598@bgtnsc04-news.ops.worldnet.att.net>
> : I don't understand if I can use
> : DBI:mysql
> : why I have to add mysql.pm again?
>
> As far as I know, I have never used the file mysql.pm when accessing mysql
> using DBI (or at any other time fro that matter).
>
> But, it is possible that it is one of the files installed when you install
> the mysql driver.
>
> Why do you think you need this file?
>
I don't have root access, so I can not install it. I only only copy the
file, so I must use "use lib dir" so I need to know what files I need to
copy from. Do you know how to add the dir to @INC without a root access on
linux?
------------------------------
Date: Sun, 21 Dec 2003 09:46:00 GMT
From: Sherm Pendley <spamfilter@dot-app.org>
Subject: Re: Is mysql.pm part of DBI?
Message-Id: <sZdFb.1108$zC4.1074924@news2.news.adelphia.net>
I Report, You Decide wrote:
> I don't have root access, so I can not install it.
First: You don't need root access to install modules. See permodinstall.
Second: You don't need to use mysql.pm, you need to use DBI. Guess what?
The DBI module has docs too - you might try reading them.
sherm--
------------------------------
Date: Sun, 21 Dec 2003 01:34:39 GMT
From: "I Report, You Decide" <test@test.com>
Subject: Re: Is Tie::CSV_File dependable on Tie:File
Message-Id: <PM6Fb.502491$0v4.21710825@bgtnsc04-news.ops.worldnet.att.net>
"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> дÈëÓʼþ
news:bs0vli$ra3$1@nets3.rz.RWTH-Aachen.DE...
> Also sprach Social Liberal-Fiscal Conservative:
>
> > http://search.cpan.org/~bigj/Tie-CSV_File-0.21/CSV_File.pm
> > says
> > There's only a small part of the whole file in memory, so this module
will
> > work also for large files. Please look the Tie::File module for any
details,
> > as I use it to read the lines of the file.
> >
> > Does that mean if I do a
> > use lib ...
> > use Tie::CSV_File
> > then I must also include
> > use lib ...
> > use Tie::File
> > in CSV_File?
>
> No, you don't that. You only have to explicitely use() Tie::File when
> you want to access its functionality in your script. If you have a
> module that makes use of it then it's the module's responsibility to
> include it.
>
> This is true not just for Tie::CSV_File but for any module. Include the
> module you want to use and don't care about how this module does its
> work.
>
> Tassilo
However, I see Tie::CSV_File calls for Tie::File, so that means I must have
Tie::File before I can use Tie::CSV
------------------------------
Date: 21 Dec 2003 01:41:41 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: Is Tie::CSV_File dependable on Tie:File
Message-Id: <Xns9457D284BB121asu1cornelledu@132.236.56.8>
"I Report, You Decide" <test@test.com> wrote in
news:PM6Fb.502491$0v4.21710825@bgtnsc04-news.ops.worldnet.att.net:
You might want to make your political statement in somewhere other than the
From: line of your posts or maybe stick with just one slogan because
constantly changing it makes it impossible to folow threads.
In addition, are you in some way affiliated with test.com? If not, you
should not be using their domain in your email address.
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: Sun, 21 Dec 2003 01:13:06 -0500
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: Is Tie::CSV_File dependable on Tie:File
Message-Id: <3FE539F2.5030709@gwu.edu>
I Report, You Decide wrote:
>
>
> However, I see Tie::CSV_File calls for Tie::File, so that means I must have
> Tie::File before I can use Tie::CSV
>
If you use CPAN to install your modules, it'll install any required
dependencies as well.
Chris Mattern
------------------------------
Date: 17 Dec 2003 16:27:21 -0500
From: Ryan Shondell <shondell@cis.ohio-state.edu>
Subject: Re: Ordering arrays?
Message-Id: <xcwbrq7dtja.fsf@psi.cis.ohio-state.edu>
Gary Mayor <gary@tgpmakers.com> writes:
> Hi,
> I'm trying to get an array into order i've got this array,
> $number[1] = "5";
> $number[2] = "7";
> $number[3] = "4";
> $number[4] = "8";
> $number[5] = "7";
>
> i'm trying to get it into another array it looks like this,
> $number2[1] = "8";
> $number2[2] = "7";
> $number2[3] = "7";
> $number2[4] = "5";
> $number2[5] = "4";
I think I would do something like this...
@number2 = reverse sort @number1;
Ryan
--
perl -e '$;=q,BllpZllla_nNanfc]^h_rpF,;@;=split//,
$;;$^R.=--$=*ord for split//,$~;sub _{for(1..4){$=
=shift;$=--if$=!=4;while($=){print chr(ord($;[$%])
+shift);$%++;$=--;}print " ";}}_(split//,$^R);q;;'
------------------------------
Date: 20 Dec 2003 19:21:35 -0800
From: tartemp@epix.net (BrokenSaint)
Subject: Parsing File
Message-Id: <24813030.0312201921.3708d8f0@posting.google.com>
i have a file with the following data:
...
Record created on 24-Jun-2003.
Database last updated on 27-Nov-2003 17:14:03 EST.
Domain servers in listed order:
ns00.nameserver.com 123.456.789.012
ns00.nameserver.com 123.456.789.012
=====================================================
What i would like to do is parse thru the file and find and retain
"NS99.WORLDNIC.COM" to a variable. The data i desire almost always is
available after the words "Domain servers...:"
=====================================================
The following 2 formats are common:
Domain servers in listed order:
ns00.nameserver.com 123.456.789.012
ns00.nameserver.com 123.456.789.012
OR
Domain servers: ns00.nameserver.com
++++++++++++++++++++++++++++++++++++++++
If someone can help me with this, it would be appreciated
------------------------------
Date: Sun, 21 Dec 2003 00:37:30 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Please critique this short script that scans a log file
Message-Id: <x7llp7xayd.fsf@mail.sysarch.com>
>>>>> "BRN" == Bill Ricker N1VUX <wdr@world.std.com> writes:
>> last unlexx /foo/ ;
> Does unlexx push tokens back on the input stream?
> ;-)
yes, it is new for 5.99 and it will be in perl6.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sat, 20 Dec 2003 20:32:19 -0500
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: Please critique this short script that scans a log file
Message-Id: <3FE4F823.3070903@gwu.edu>
Bill Ricker N1VUX wrote:
>>last unlexx /foo/ ;
>
>
> Does unlexx push tokens back on the input stream?
>
No, it just gets a rather strange SF television series
cancelled :-).
Chris Mattern
------------------------------
Date: Sat, 20 Dec 2003 17:45:02 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: replacing two EOL chars by one
Message-Id: <slrnbu9nnu.o8o.tadmc@magna.augustmail.com>
Xah Lee <xah@xahlee.org> wrote:
> Fucking stupid perl couldn't do a simple task of
> replacing strings.
You are mistaken.
It is the fucking stupid Perl _programmer_ who could not do a simple
task of replacing strings.
You have become mundane, sloppy and fatuous.
You should stop programming in Perl as it will only get worse.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 20 Dec 2003 20:13:39 -0500
From: Greg Menke <gregm-news@toadmail.com>
Subject: Re: replacing two EOL chars by one
Message-Id: <m3y8t7q8fw.fsf@europa.pienet>
xah@xahlee.org (Xah Lee) writes:
> i have a bunch of java files that has spaced-out formatting that i
> want to get rid of. I want to replace two end of line characters by
> one end of line characters. The files in question is unix, and i'm
> also working under unix, so i did:
Have a look at tr and sed. tr is also a handy tool for fixing Windows
cr/lf madness.
Gregm
------------------------------
Date: 21 Dec 2003 02:36:04 +0100
From: Pascal Bourguignon <spam@thalassa.informatimago.com>
Subject: Re: replacing two EOL chars by one
Message-Id: <877k0rgdff.fsf@thalassa.informatimago.com>
"Paul McGuire" <ptmcg@austin.rr.com> writes:
> Is this language really necessary? I'm sure I've used these words myself,
> but they're certainly not appropriate in a public discussion.
We don't get the usenet "in color" around here, so I guess that this
languages reflected the fuming hot in frustration state of the OP. I
guess that you could measure the quality of a design and its
documentations by the inverse of the number of posts related to it
using such language.
When we'll have video-usenet, I guess language will be more proper,
but we'll be seeing keyboads and screens flying out of the windows
more often.
> I do not know the answer to your question, it really seems more like a
> regexp question, rather than a problem with Perl. I hope someone who knows
> the answer can respond, hopefully in more civil language.
Even with sed I find difficult to do that.
On the other hand, with emacs it's quite simple:
M-x replace-string RET C-q C-j C-q C-j RET C-q C-j RET
--
__Pascal_Bourguignon__ . * * . * .* .
http://www.informatimago.com/ . * . .*
There is no worse tyranny than to force * . . /\ ( . *
a man to pay for what he does not . . / .\ . * .
want merely because you think it .*. / * \ . .
would be good for him. -- Robert Heinlein . /* o \ .
http://www.theadvocates.org/ * '''||''' .
SCO Spam-magnet: postmaster@sco.com ******************
------------------------------
Date: 21 Dec 2003 02:38:49 GMT
From: Jesse Tov <tov@eecs.harvREMOVEard.edu>
Subject: Re: replacing two EOL chars by one
Message-Id: <slrnbua1tp.qaq.tov@tov.student.harvard.edu>
Pascal Bourguignon <spam@thalassa.informatimago.com>:
> Even with sed I find difficult to do that.
If you want to remove blank lines, then sed '/^$/d' will do. If, on
the other hand, you actually want to compress pairs of newlines into
single newlines (as I think the specification may have said), something
a bit more complicated is required. I think that sed 'N;P;/\n$/d;D'
will do it.
Jesse
------------------------------
Date: 21 Dec 2003 03:57:26 GMT
From: Jesse Tov <tov@eecs.harvREMOVEard.edu>
Subject: Re: replacing two EOL chars by one
Message-Id: <slrnbua6h6.qaq.tov@tov.student.harvard.edu>
Pascal Bourguignon <spam@thalassa.informatimago.com>:
> Even with sed I find difficult to do that.
If you want to remove blank lines, then sed '/^$/d' will do. If, on
the other hand, you actually want to compress pairs of newlines into
single newlines (as I think the specification may have said), something
a bit more complicated is required. I think that sed 'N;P;/\n$/d;D'
will do it.
If you want to use Perl or Ruby, these are equivalent to the first sed
solution:
ruby -ne 'print unless /^$/'
perl -ne 'print unless /^$/'
In Ruby you might also use:
ruby -pe 'next if /^$/'
The equivalent doesn't work in Perl, probably because -p puts the
implicit print statement in a "continue" block, which gets executed
before the loop is restarted by "next".
If you're doing this on a huge file and care about speed, sed will
be slightly faster than Perl and Perl will blow Ruby away. Because
I was curious, I tried writing it in C to see if I could beat sed.
My first attempt was slightly slower (!), but my second attempt ran
much faster than sed; unfortunately, it also took 30 minutes and
34 lines.
Jesse
------------------------------
Date: 21 Dec 2003 01:06:34 -0800
From: xah@xahlee.org (Xah Lee)
Subject: Re: replacing two EOL chars by one
Message-Id: <7fe97cc4.0312210106.5a72c199@posting.google.com>
Ragnar Hafsta? (gnari@simnet.is) wrote:
> you are forgetting what -p does
> ...
> perl -0 -pi'*~' -e 's@\n\n@\n@g' *.java
Thank you kindly.
--
Now there are a slew of perl driviling morons who
has also participated in answering to no avail. Die!
PS pasted below my sig is some meat about unix. Unix morons please
slurp and spruce it up and place it on wikipedia.org or something.
Xah
xah@xahlee.org
http://xahlee.org/PageTwo_dir/more.html
From: xah@xahlee.org
Subject: unix inanity: shell env syntax
Date: June 7, 2002 12:00:29 AM PDT
To: macosx-talk@omnigroup.com
Unix Syntatical and Semantical Stupidity Exposition.
(this is one of the many technical expositions of unix stupidity)
(this is currently unpolished, but the meat is there. Input welcome.)
------------
arguments are given with a dash prefix.
e.g.
ls -a -l
order (usually) does not matter. So,
ls -a -l
is the same as
ls -l -a
but arguments can be combined
e.g.
ls -al
means the same thing as
ls -a -l
However, some option consists of more than one character.
e.g.,
perl -version
perl -help
therefore, the meaning of an option string "-ab" is ad hoc dependent
on the program. It can be "-a -b" or just an option named "ab".
Then, sometimes there are two versions of the same optional argument.
e.g.
perl -help
perl -h
perl -version
perl -v
this equivalence is ad hoc.
Different program will disagree on common options. For example, to get
the version, here are common varieties
-v
-V
-version
sometimes v/V stands for "verbose mode", i.e. to output more detail.
Sometimes, if an option is given more than once, then it specifies a
degree of that option. For example, some command accept the -v for
"verbose", meaning that it will output more detail. Sometimes there
are few levels of detail. The number of times an option is specifies
determines the level of detail.
e.g. on Solaris 8,
/usr/ucb/ps -w
/usr/ucb/ps -w -w
thus, meaning of repeated option may have special meaning depending on
the program.
oftentimes some options automatically turn on or supress a bunch of
others. e.g.
Solaris 8, /usr/bin/ls -f
--
when a named optional parameter is of a boolean type, that is a toggle
of yes/no, true/false, exist/nonexist, then it is often times that
instead of taking a boolean value, their sole existance or
non-existance defines their value.
toggle options are sometimes represented by one option name for yes,
while another option name for no, and when both are present, the
behavior is program dependent.
--
toggle option are represented by different option names
--
for named options, their syntax is slack but behavior is usually
dependent on the program.
i.e. not all of the following works for every program
command -o="myvalue"
command -omyvalue
comand -o myvalue
--
often one option may have many synonyms...
--
an example of a better design... (Mathematica, Scheme, Dylan, Python,
Ruby... there's quite a lot elegance and practicality yet distinct
designs and purposes and styles ...)
(recall that unix does not have a bad design to begin with; it's a
donkey shit pile from the beginning and continuation. Again, unix is
not simply technically incompetent. If that, then that's easy to
improve, and i don't have a problem with, since there are things in
one way or another considered horrendous by today's standard like
COBOL or FORTRAN or DOS etc. But, unix is a brain-washing idiot-making
machine, churning out piles and piles of religiously idiotic and
pigheaded keyboard punchers. For EVERY aspects of good engineering
methodology improvement or language design progress opportunity,
unixers will unanimously turn it down.
inevitably someone will ask me what's my point. My point in my series
of unix-showcasing articles has always been clear for those who
studies it: Unix is a crime that caused society inordinate harm, and i
want unix geeks to wakeup and realize it.
Xah
xah@xahlee.org
http://xahlee.org/PageTwo_dir/more.html
From: xah@xahlee.org
Subject: Re: mail handling/conversion between OSes/apps
Date: May 12, 2002 8:41:58 PM PDT
Cc: macosx-talk@omnigroup.com
...
Yes, unix have this beautiful philosophy. The philosophy is functional
programing.
for example, define
power(x) := x*x
so
power(3) returns 9.
here 'power' is a function that takes 2 arguments. First parameter
specifies the number to be raised to power, the second the number of
times to multiply itself.
functions can be nested,
f(g(h(x)))
or composed
compose(f,g,h)(x)
here the 'compose' itself is a function, which take other functions as
arguments, and the output of compose is a new function that is
equivalent to nesting f g h.
nesting does not necessarily involved nested syntax. Here's a post fix
notation in Mathematica for example:
x /. h /. g /. h
or prefix notation.
f @ g @ h @ x
or in lisp
(f (g (h x)))
--
the principle is that everything is either a function definition or
function application, and function's behavior is strictly determined
by its argument.
Apple around 1997 or so have this OpenDoc technology, which is similar
idea applied more broadly across OS. That is, instead of one
monolithic browser or big image editors or other software, but have
lots of small tools or components that each does one specific thing
and all can call each other or embedded in an application framework
as services or the like. For example, in an email apps, you can use
BBEdit to write you email, use Microsoft's spell checker, use XYZ
brand of recorder to record a message, without having to open many
applications or use the Finder the way we would do today. This
multiplies flexibility. (OpenDoc was killed when Steve Jobs become the
iCEO around 1998 and did some serious house-keeping, against the
ghastly anger of Mac developers and fanatics, I'm sure many of you
remember this piece of history.)
The unix pipe syntax |, is a post-fix notation for nesting. e.g.
ps auwwx | awk '{print $2}' | sort -n | xargs echo
in conventional syntax it might look like this:
xargs( echo, sort(n, awk('print $2', ps(auwwx))) )
So when you use "pipe" to string many commands in unix, you are doing
supreme functional programing. That's why it is so flexible and
useful, because each component or function does one thing, and you can
combine them in myriad of ways. However, this beautiful functional
programing idea, when it is implemented by the unix heads, becomes a
fucking mess. Nothing works and nothing works right.
I don't feel like writing a comprehensive exposition on this at the
moment. Here's a quick summary:
* fantastically stupid syntax.
* inconsistencies everywhere. everywhere.
* fucking stupid global variables reliance called environment
variables, which fuck up the whole functional programing paradigm.
* implicit stuff everywhere.
* totally incompetent commands and their parameters. (promiscuously
non-orthogonal, and missing things, and fucked up in just more ways
than one can possibly imagine. there are one million way to do one
thing, and none are correct, and much simple needs CANNOT be done!
(that's why there are gazillion shells each smart-ass improving upon
the other, and that's why Perl is born too! But asinine Larry Wall
don't know shit but smugly created another complexity that don't do
much.))
maybe some other day when i'm pissed, i'll write a better exposition
on this issue. I've been wanting to write a final-say essay on this
for long. Don't feel like it now.
Xah
xah@xahlee.org
http://xahlee.org/PageTwo_dir/more.html
------------------------------
Date: 20 Dec 2003 17:31:38 -0800
From: e9526925@stud3.tuwien.ac.at (Rasto Levrinc)
Subject: Re: sum of numbers
Message-Id: <e4807da1.0312201731.474193a8@posting.google.com>
Tassos <chatasos@yahoo.com> wrote in message news:<1071828484.212677@athnrd02.forthnet.gr>...
> Is there a way to find the sum of the following numbers (stored in a file) using a single
> line (perl -pe) command?
>
>
> 254257
> 52658768
> 19320
> 135
> 5070180
> 14392
> 7113
> 24415
> 34983006
> 7329
> 50584
> 24481
> 91
> 8339
> 14407
perl -npe'$\+=$_}{' yourfile
Rasto Levrinc
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 5966
***************************************