HDTenEightyP/NetNews huggingface dataset:
From: mark@coombs.anu.edu.au (Mark)
Newsgroups: comp.lang.perl
Subject: Re: Japanese character stuff (Was: Perl 5 and Latin-1)
Date: 19 Dec 92 12:39:48 GMT
Organization: Australian National University
NNTP-Posting-Host: 150.203.76.2
Organisation: Wassat?!

barnett@paintbrush.mcc.com (Jim Barnett) writes:

>kono@csl.sony.co.jp (Shinji Kono) writes:


>   Support for 8bit char and multi-byte code sounds very good. I heard
>   there is a two byte char code version of perl for Japanese.

>Could anyone point me to this version of Perl? We're doing a project
>involving a large amount of Japanese text, and a 2-byte version would
>be a big help. I've been able to trick the regexp matcher into doing
>simple matches, but fancier things would be a problem.

I'm not sure about the C code version but I'm sure if you ftp'd to
sra.co.jp you would find some joy there...

Here is the header to a file on coombs.anu.edu.au in /pub/perl/scripts:

;# jcode.pl: Japanese character code conversion library
;#
;# Copyright (c) 1991,1992 Software Research Associates, Inc.
;#	Original by srekcah@sra.co.jp, Feb 1992
;#
;#	Maintained by Kazumasa Utashiro <utashiro@sra.co.jp>
;#	Software Research Associates, Inc., Japan

Hope this helps..

Mark
mark@coombs.anu.edu.au
From: hans@symbas.UUCP (Hans Aafloy)
Newsgroups: comp.lang.perl
Subject: negation in Regular Xpr.
Date: 17 Dec 92 16:56:36 GMT
Reply-To: hans@symbas.lind.no
Distribution: world
Organization: Symbiotic Computer Systems A/S, Trondheim, Norway

/^pattern/   matches when the pattern is encountered at the start
             of the line.
             But in such cases I eant to  a v o i d  the rule to fire.
             How do I do that ?
             Is there any way to negate a character's special meaning ?

             Thankful for e-mailed answers.
 
             hans@symbas.lind.no
   
Newsgroups: comp.lang.perl
From: shobhana@shakti.ncst.ernet.in (Shobhana)
Subject: Re: System V curseperl on a Sun?  How?
Keywords: System V curseperl Sun
Organization: CMIE, Bombay
Date: Tue, 15 Dec 1992 08:48:54 GMT

In article <1frpfiINNq1u@crcnis1.unl.edu> mosemann@unl.edu writes:

>   I have built curseperl on a Sun (SunOS 4.1.3) using the
>bsdcurses.mus.  System V curses seems to include a few more goodies, so
>I was thinking of using that package instead.  However, I have not been
>able to build such an animal.  Has anyone been able to do this?  What do
>I need to do?  Thanks.

Simply add / modify the CFLAGS and LDFLAGS in your Makefile to read

CFLAGS=-I.. -I/usr/5include -DUSG
LDFLAGS=-L/usr/5lib

And yes, of course, use curses.mus

Best luck.
Shobhana
--
Shobhana Vyas		shobhana@shakti.ncst.ernet.in


Newsgroups: comp.lang.perl
From: cameron@spectrum.cs.unsw.oz.au (Cameron Simpson)
Subject: Re: programming challenge
Reply-To: cameron@spectrum.cs.unsw.oz.au (Cameron Simpson)
Organization: CS&E Computing Facility, Uni Of NSW, Oz
Date: Wed, 16 Dec 1992 08:18:36 GMT

gnb@baby.bby.com.au (Gregory N. Bond) writes:
| If you are editing man pages, they probably contain things like
| E^HE to make things bold, and _^HE (or E^H_, depending on your
| nroff) to underline them.  Rather than stripping the ^Hs then
| compressing the repeats, what about doing both at once:
| 
| 	perl -pi.bak -e 's/(.)\cH$1/$1/g;s/_\cH(.)/$1/g;' {files}
| 
| (NB: \b is word boundry in regexps! Use ^H instead!)

Ugh. Unless I'm missing something basic, this will work (and I've used this
script for years):

	#!/bin/sh
	#
	# Remove nroff-style underlining and overstriking.
	# Works for other stuff, too.
	#

	exec sed 's/.^H//g' ${1+"$@"}

Thus,
	unbs man.out > man.text

It starts up much faster than Perl. That ^H is a literal control-H, guys.
	- Cameron Simpson
	  cameron@cs.unsw.oz.au, DoD 0743
--
"The engine purrs beneath me with a purpose,
 ready for the pleasure of my hand upon the throttle." - Peter Smith
Newsgroups: comp.lang.perl
From: rray@lookout.it.uswc.uswest.com (Randy J. Ray)
Subject: Package & Namespace Question
Organization: US WEST Communications, Inc. -- Denver, CO
Date: Wed, 16 Dec 1992 17:27:31 GMT

Having coded quite a bit, and become somewhat familiar with this language, I
have a question of curiousity. This is not intended to be critical of any
design choices on the part of the perl creators, but it's something I would
like to know.

Why is it that: when calling subroutines defined in the main namespace from
within some package, you must explicitly refer to main? Why is there not some
syntactical rule that says, "If this routine is not defined at this level, look
for it in main before reporting an error"? I can understand specifying
&main'phred() when you want to use that instead of a package-defined &phred.
Is it that main is not necessarily above other packages in hierarchy, and
therefore it is not the natural progression to look for those routines
elsewhere?

Randy
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Randy J. Ray -- U S WEST IT/CSD                 rray@lookout.it.uswc.uswest.com
                                                           Phone: (303)595-2852
"It's not denial. I'm just very selective about the reality I accept." --Calvin
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: merlyn@ora.com (Randal L. Schwartz)
Newsgroups: comp.lang.perl
Subject: Re: Perl IV & V incompatibilities?
Date: 18 Dec 92 17:11:33 GMT
Article-I.D.: romulus.MERLYN.92Dec18091127
	<FAIGIN.92Dec17134910@soldan.aero.org>
Organization: Stonehenge Consulting Services; Portland, Oregon, USA

In article <FAIGIN.92Dec17134910@soldan.aero.org> faigin@aero.org (Daniel P. Faigin) writes:
   I'm sure it won't be worse than the transition from Perl 0 to Perl 1 was. But
   then, Larry, Mark, and I were the only users of Perl 0, back in our blacker
   (so to speak :-)) days. Perl 1 was the first version released to the net,
   after Larry had moved over to RandD at SDC (hence, the machine name, sdcrdcf).

   One of these days, when my beard gets more grizzed, I'll tell you children the
   story :-)

For those of you that don't know, Dan is the tale-spinner of the
"history of Perl" in the Camel book.  He should know.

print "Just another Perl [book] hacker,"
--
Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
merlyn@ora.com (semi-permanent) merlyn@reed.edu (for newsreading only)
factoid: "Portland, Oregon, home of the California Raisins and Lone-Star Beer!"
From: marcr@studsys.mscs.mu.edu (Marc Rassbach)
Newsgroups: comp.lang.perl
Subject: Perl 4.035 on Esix V.4.0.3 op/magic 4 op/readdir 2
Date: 20 Dec 92 17:56:33 GMT
Reply-To: marcr@studsys.mscs.mu.edu (Marc Rassbach)
Organization: Marquette University - Department MSCS
NNTP-Posting-Host: studsys.mscs.mu.edu
Originator: marcr@studsys.mscs.mu.edu

(I hope the title is descriptive enuf)

I'm trying to get perl up on a Esix V.4.0.3 box.  When I run the
regressive tests, it chokes on the regression tests op/magic FAILED on test 4
and op/readdir FAILED on test 2  

It was complaining about dc being re-defined in readdir.o, but it seemed
the EXT char *dc def was for debugging, so I commented it out.  (and it
was failing before the commenting out.)

Ideas?

-- 
Marc Rassbach    marcr@studsys.mscs.mu.edu    If you take my advice, that
MS-DOS - it's not   marc@milestn.mil.wi.us    is your problem, not mine!
my problem!     If it was said on UseNet, it must be true.
   Unix - It's a nice place to live, but you don't want to visit there.
Newsgroups: comp.lang.perl
From: mcook@fendahl.dev.cdx.mot.com (Michael Cook)
Subject: Re: Help on string match!
Organization: Motorola Codex, Canton, Massachusetts
Distribution: na
Date: Sat, 19 Dec 1992 00:18:25 GMT

tesh@cleo.Eng.Sun.COM (Teshager Tesfaye) writes:

[...]

>	foreach $a_name ( @A_array ) {
>		for(;;) {

>			if( $_ =~ "^ +[JKD]FF" ) {
>				local($macname,$fname_net,$other) = split(' ',$_,3);

>  ------->	if ( $a_name eq $flop_name ) {

[...]

>I am having with the string match on the line that I show. Although I know
>that $a_name and $flop_name are identical strings this string match "ALWAYS"
>fails. Am I doing something wrong? Is there a better way to go about this
>problem.

If you've taken logical steps and reached an illogical conclusion, then one of
your assumptions must have been invalid.

How is it that you know that $a_name and $flop_name are identical?  How is it
that you know that the comparison is being made?  ...that the comparison is
failing?

Some strategically-placed print statements will tell you what is going on.
Don't forget to allow for trailing whitespace and non-printing characters
(consider piping your script's output through "cat -ve", or somesuch).

Michael.
From: mark@coombs.anu.edu.au (Mark)
Newsgroups: comp.lang.perl
Subject: Re: Thanks to all of you that bought camel books!
Date: 14 Dec 92 14:19:12 GMT
Organization: Australian National University
NNTP-Posting-Host: 150.203.76.2
Organisation: Wassat?!

merlyn@ora.com (Randal L. Schwartz) writes:

>I just got my third quarter royalty check in the mail, and was
>pleasently surprised.  Nearly 4000 people bought camel books during
>July, August, and September (yes, we don't get the checks for 60+ days
>after the end of the quarter).  That also means that OR&A has printed
>and sold about 20,000 books since the release last January.

>And be watching *soon* for Learning Perl (which would be getting done
>faster if there wasn't ten new inches of snow on Mt. Hood today....
>ackcckck!) appearing on OR&A shelves around the world.

I'm waiting for the book for perl 5.0... will there be a new edition to cover
it or will the man page suffice? (Who reads it anyway, I havent as yet. The
Book is much better.. (I read enough to go buy the book)).

Mark
mark@coombs.anu.edu.au
From: serickso@ub.d.umn.edu (Scott Erickson)
Newsgroups: comp.lang.perl
Subject: Removing duplicate array members. How?
Date: 14 Dec 1992 14:40:39 -0600
Organization: School of Conformist Thought
Distribution: usa
Reply-To: serickso@ub.d.umn.edu
NNTP-Posting-Host: ub.d.umn.edu

Hello:

  I am trying to remove duplicate members from an array.  Is there any
construct in Perl, such as maybe using grep, that will only give me an array
with no duplicated members? An example:

Contents of array @ARRAY:  item1 item2 item2 item3
Contents after removal:    item1 item2 item3

  I have another array with members that are a subpart of the members of the
first array.  An example:

Contents of array @ARRAY1: (part1 part2)1 (part1 part2)2
Contents of array @ARRAY2: (part1)1 (part1)2

  I want to use the information of part2 of the items in the second array,
but what I am doing later requires a loop and having duplicate members in the
array is undesirable.  The contents of the two arrays are acquired through
different means.  The contents of the one array arquired through the Unix
command "finger" and the contents of the second command are acquired through
either command line arguments or from standard input.

  I suppose I could use a loop and copy only single members to another array,
but this is only useful if I have a small array.

  Also, I do not know the size of the array until during execution.

  In case you are wondering what this is for, I am writing a Perl script that
when given a users login name will attempt to find out where they are and
then display what room and/or what computer they are using.  An example:
%where serickso
serickso: monh23913.d.umn.edu MonH239 Macintosh 13

  Most of our computers are ethernetted or connected to a Apple Localtalk
network, thus in most cases I can determine exactly what computer they are
at.  This is useful if I want to find out where a friend of mine is.  The
only drawback is that I need to maintain a sitelist that maps a domain name
to a room/computer.

  Your help will be appreciated.

-- 
serickso@ub.d.umn.edu                                         Scott Erickson
From: tesh@cleo.Eng.Sun.COM (Teshager Tesfaye)
Newsgroups: comp.lang.perl
Subject: Help on string match!
Date: 18 Dec 1992 21:07:40 GMT
Organization: Sun Microsystems, Inc.  Mt. View, Ca.
Distribution: na
Reply-To: tesh@cleo.Eng.Sun.COM (Teshager Tesfaye)
NNTP-Posting-Host: cleo


I have two "Big" files that I read into arrays:
	File A - contains the string to be matched
	File B - is the file on which the match is performed on.

Task:  

	I want to match each string in A inside B and append string,
	STRING, after the match. So my final file C, should be a copy
	of B with inserted STRING's .

The following is the approach I took but did not work:

	foreach $a_name ( @A_array ) {
		for(;;) {

			if( $_ =~ "^ +[JKD]FF" ) {
				local($macname,$fname_net,$other) = split(' ',$_,3);

  ------->	if ( $a_name eq $flop_name ) {

					# do something

					&add_str_routine( x );
					last; 
				}

				else {
					next;
				}
		}
	}


I am having with the string match on the line that I show. Although
I know that $a_name and $flop_name are identical strings this string
match "ALWAYS" fails. Am I doing something wrong? Is there a better 
way to go about this problem.

Thanks in advance.

Tesh.
From: lwall@netlabs.com (Larry Wall)
Newsgroups: comp.lang.perl
Subject: Re: Is this a perl bug?
Date: 12 Dec 92 07:26:51 GMT
Organization: NetLabs, Inc.

In article <9212111642.AA27958@brimstone.unipalm.co.uk> ian (Ian Phillipps) writes:
: lwall@netlabs.com (Larry Wall) writes:
: 
: >And why have I put off formats for so long?  Guess where a lot of the
: >most ancientest and most decrepitudinous code in Perl is.
: 
: Why not write them in perl?
: A few quick hacks, an eval, and away you go. Maybe.

Well, in actual fact, in Perl 5, the tokener turns a format into a
strange sort of subroutine, which calls one or more statements
containing a list operator called "formline".  You can call formline
yourself if you want to do something funky.

Similarly, when you say "\u\L$foo\E$bar", the tokener turns that into
(ucfirst(lc($foo)) . $bar).  You can call uc(), lc(), ucfirst() and
lcfirst() yourself if you like.  Similarly, `cat $foo` turns into
something like backtick('cat ' . $foo), though I haven't actually put
in a keyword to access that function yet.  The m// and s/// stuff works
similarly.

Anyway, formats are completely rewritten now, and work, and I'm at 95.89%.
I'm now to the point where I have to start putting in lexical scoping
and references to make any more progress.

The 3 tests that are still failing use most of the cpu time they would
anyway, so I compared the timings of Perl 4 on the regression tests
with Perl 5.  With both compiled -g -DDEBUGGING, I got:

    Perl4: 11.4u 16.8s 0:48
    Perl5:  9.4u 10.5s 0:36

For something that I've done almost no optimization on except for constant
folding, that's not too shabby...

I suspect that the difference in system time comes from longjmp() avoidance.

: BTW - I've used most bits of Perl (but *foo='bar' still has me
: baffled), but I've never actually *used* formats - although they've
: appeared in early drafts of some of my efforts.
: 
: In every case I've met, "printf" does what I want and formats don't,
: mostly because of what happens when the variable is too wide for the
: field - I'm in the "keep the data a blow the format" party.

Hmm, I might be able to give you overflowable fields with the new
format code.  What about something like @<<<<*, analogous to the @*
thingy?  I suppose that would imply a minimum width of 2 for @*, but
that's probably okay, since it would generally turn into 2 spaces that
would get eaten up before the newline anyway.

One could also imagine specifying that as *<<<<<, since ^<<<<* doesn't
really make much sense, but I don't think I want to introduce another
initial metacharacter.  On top of which, ^###.#* does make some sense,
not to mention cents.

Larry
From: absinthe@viva.chem.washington.edu (Daniel Faken)
Newsgroups: comp.lang.perl
Subject: Matching sequences NOT containing certain subsequences
Date: 19 Dec 92 12:33:17 GMT
Article-I.D.: u.1992Dec19.123317.10830
Reply-To: absinthe@u.washington.edu
Organization: University of Washington

I want to match the outermost parentheses in things like
  (foo) and (foo\)), but not (foo()).
I tried something like
  /([^\\]\)){0}/
 but got the message:
  Can't do {0} at OC line xx.  [perl 4.0.1.7/33]

How is this sort of thing normally done (within one match)?
thanks,
--
      Daniel Faken          |    Name a poison,
absinthe@u.washington.edu   |    pick your flavour.
Newsgroups: comp.lang.perl
From: gnb@baby.bby.com.au (Gregory N. Bond)
Subject: Re: programming challenge
Organization: Burdett, Buckeridge & Young, Melbourne, Australia
Date: Wed, 16 Dec 1992 04:31:28 GMT

If you are editing man pages, they probably contain things like
E^HE to make things bold, and _^HE (or E^H_, depending on your
nroff) to underline them.  Rather than stripping the ^Hs then
compressing the repeats, what about doing both at once:

	perl -pi.bak -e 's/(.)\cH$1/$1/g;s/_\cH(.)/$1/g;' {files}

(NB: \b is word boundry in regexps! Use ^H instead!)

Greg.
--
Gregory Bond <gnb@bby.com.au> Burdett Buckeridge & Young Ltd Melbourne Australia
      If I hear "Jingle Bell Rock" one more time, I will _scream_!


Newsgroups: comp.lang.perl
From: Tom Christiansen <tchrist@convex.COM>
Subject: Re: system() vs exec()
Originator: tchrist@pixel.convex.com
Date: Wed, 16 Dec 1992 16:08:45 GMT
Reply-To: tchrist@convex.COM (Tom Christiansen)
Organization: Convex Computer Corporation, Colorado Springs, CO
X-Disclaimer: This message was written by a user at CONVEX Computer
              Corp. The opinions expressed are those of the user and
              not necessarily those of CONVEX.

From the keyboard of mcook@fendahl.dev.cdx.mot.com (Michael Cook):
:This means that a Perl script that use system() can be difficult to interrupt.
:  foreach (@files)
:  {
:    system("cp $_ $dest/$_");
:    $exit = $? if $?;
:  }
:  exit($exit);
:
:If you try to ^C this script, it will simply start a new iteration of the
:foreach loop (most likely).
:
:If you write the script using fork, exec and waitpid, when you hit ^C it does
:what you'd expect: it dies.
:
:At best, this is a bug in the manpage.  At worst, it is a bug in perl.

Well, it's really just behaving like system(3) out of the C library.
You can always check ($signo = $? & 127) on many systems, or write

    sub system { fork ? wait : exec @_ }

--tom
-- 
    Tom Christiansen      tchrist@convex.com      convex!tchrist
There are probably better ways to do that, but it would make the parser
more complex.  I do, occasionally, struggle feebly against complexity...  :-)
            --Larry Wall in <7886@jpl-devvax.JPL.NASA.GOV>
Newsgroups: comp.lang.perl
From: jon@cas.org (Jon Vander Hill)
Subject: Re: timing problem with $SIG{'CHLD'}
Organization: Chemical Abstracts Service, Columbus, Ohio
Date: Sat, 12 Dec 1992 12:34:44 GMT

>>>>> On Fri, 11 Dec 1992 07:33:01 GMT, ccechk@nuscc.nus.sg (Heng Kek) said:

> mlo@cray.com (Mick Oyer) writes:
> : I'm trying to set up a daemon, written in perl, that will listen
> : for messages coming across the network.  I used the client/server
> : model in the Camel book as a starting point, but am running into
> : a sticky situation.
> : 
> [..deleted..]
> : I'm setting $SIG{'CHLD'} to reap the zombies.
> : The problem:
> : my code is blocking on the 'accept' call.  When the child
> : exits, the CHLD signal causes reaper to get called, interfering
> : with the accept:
> : 	Interrupted system call at ./modinfod line 45.
> : 
> : 	(line 45):	($addr = accept(NS,S)) || die $!;
> : 

> I had EXACTLY the same problem.  My work-around was to re-invoke
> 'accept()' when it dies as per the problem above.  I use:

>   ($addr = accept(KK,S)) || ($addr = accept(KK,S)) || 
>                              die "accept:$!\n";
>             # ..to avoid accept() dying and killing the prog.

> Any criticism on this method is most welcome as I'd like to learn
> too.

Here's an alternative approach:

for(;;) {
    $addr = accept(NS,S);
    if (!defined $addr) {
	next if $! =~ /^Interrupted/;
	die "$0: accept failed: $!\n";
    }
    ...
}

Jon Vander Hill
jon@cas.org
From: pete@egh-qc.uucp (Pete Phillips)
Newsgroups: comp.lang.perl
Subject: Re: Statistic routines ?
Keywords: statistic
Date: 17 Dec 92 13:22:48 GMT
Organization: Surgical Materials Testing Laboratory

lendl@cosy.sbg.ac.at (Otmar Lendl) writes:

>I have to do some statistical analysis of data I gather with
>perl scripts, so it would be convenient to use perl for that
>purpose, too.

>Before I start to write my own set of functions (Mean, standard-deviation,
>histograms, ...) I better ask if there are already such beasts.
>I checked the script-archives listed in the FAQs (convex, ohio-state),
>but could not find anything suitable.

>Can anyone give me pointers ?

Well, why bother to write statistics in perl ?  Why not just interface
your perl routines to Gary Perlmans STAT| package ?

I recently did some work where I had various columns of data that
needed basic statistical data.  Here are some code snippets to show
you how I did it (basically I had to read a stack of data and select
only certain columns etc, which was pretty ugly, so I've included just
what you need - if you want the rest of the code, mail me):

# do statistics
sub statistics {
    foreach $elem (2..25) {     # for each column from 2-25
        @st=eval "\@d$elem";
        $stats=`echo @st | stats mean sd skew kurt`;
        ($mean[$elem],$sd[$elem],$skew[$elem],$kurt[$elem])=split(' ',$stats);
    }
}



# print statistics
sub print_statistics {
    print "=\n";
    foreach $stat_test ("mean","sd","skew","kurt") { # mean, sd, kurt & skew
        print "$stat_test";
        foreach $elem (2..25) {
            printf (":%4.2f",eval "\$$stat_test[\$elem]");
        }
        print "\n";
        
    }
    
}
-- 
Pete Phillips, Surgical Materials Testing Lab, Bridgend, S. Wales.
UUCP   :  uknet!egh-qc!pete            DOMAIN :  pete@egh-qc.co.uk
-----------------------------------------------------------------
"SCIENCE: A way of finding things out and then making them work.  
Newsgroups: comp.lang.perl
From: lwall@netlabs.com (Larry Wall)
Subject: Re: In 5.0, are we gonna get...
Organization: NetLabs, Inc.
Date: Sat, 19 Dec 1992 02:12:41 GMT

In article <1992Dec18.140112.18192@cs.ruu.nl> henkp@cs.ruu.nl (Henk Penning) writes:
:   I would like to write:
: 
:     $max = reduce { $a >  $b ? $a : $b } @row

The credit-where-credit-is-due department:  it should be pointed out
that Henk suggested the reduce {$a + $b} @stuff syntax in the first
place, which is why I happened to be talking about it with Mark.

It seems to fit in nicely with the sort paradigm, if you can grace that
construct with such a heavy-duty word.  The interesting part is figuring
out how to optimize it...

Larry
From: neumann@dec4.wu-wien.ac.at (Gustaf Neumann)
Newsgroups: comp.lang.perl
Subject: Re: In 5.0, are we gonna get...
Date: Fri, 18 Dec 92 20:10:07 MET
Organization: WU-Wien
Distribution: world
NNTP-Posting-Host: dec4.wu-wien.ac.at

In article <1992Dec18.140112.18192@cs.ruu.nl> from [Fri, 18 Dec 1992 14:01:12 GMT] you wrote:
 |> 
 |>   I would like to write:
 |> 
 |>     $max = reduce { $a >  $b ? $a : $b } @row
 |>   
 |> -- Another idea would be to have a reduce in array-context,
 |>    for example to squeeze out adjacent equal elements:
 |> 
 |>      @uniq = reduce { ($a eq $b) ? ($a) : ($a,$b) } @row
 |>    
 |>    Here the ab-sub is evaluated in array-context. The first time
 |>    $a is the first element of @row, later on the last element
 |>    of the partial result.

this examples are still pretty trivial in current perl:

sub reduce {
    local($f,@array) = @_;
    local($a) = shift @array;

    return $a unless @array;
    local($b) = &red($f,@array);
    return eval $f;
}

print &reduce('$a >  $b ? $a : $b',1,6,5,8,3,4),"\n";
print &reduce('$a <  $b ? $a : $b',1,6,5,8,3,4),"\n";
print &reduce('$a + $b',1,6,5,8,3,4),"\n";

your array examples are more tricky.
-gustaf
--
Gustaf Neumann          neumann@dec4.wu-wien.ac.at, neumann@awiwuw11.bitnet
Vienna University of Economics and Business Administration 
Augasse 2-6,  A-1090 Vienna, Austria		
Tel: +43 (222) 31-336 x4533  	Fax: 347-555

Newsgroups: comp.lang.perl