From: REGI's <NUNEZ@esevvx.cica.es>
Subject: (none)
Reply-To: NUNEZ@esevvx.cica.es
Organization: The Internet
Date: Thu, 15 Oct 1992 11:57:24 GMT

|X-Envelope-to: Perl-Users@fuggles.acc.Virginia.edu
|X-VMS-To: IN::"      Perl-Users@fuggles.acc.Virginia.EDU"

1
16-OCT-1992 08:29:57.26
   1 00:00:00.00
17-OCT-1992 08:29:57.26
perl-users-dist-request@fuggles.acc.Virginia.EDU
rafapa@obelix.cica.es

Received: from fuggles.acc.Virginia.EDU by ESEVVX.CICA.ES ; 13-OCT-1992 08:29:45.62
Received: from fuggles.acc.Virginia.EDU by fuggles.acc.Virginia.EDU id aa14658;
          13 Oct 92 3:13 EDT
Received: from uvaarpa.virginia.edu by fuggles.acc.Virginia.EDU id aa14654;
          13 Oct 92 3:12 EDT
From:     Digestifier <Perl-Users-Request@fuggles.acc.Virginia.EDU>
To:       Perl-Users@fuggles.acc.Virginia.EDU
Reply-To: Perl-Users@fuggles.acc.Virginia.EDU
Date:     Tue, 13 Oct 92 03:12:08 EDT
Subject:  Perl-Users Digest #602

Perl-Users Digest #602, Volume #2                Tue, 13 Oct 92 03:12:08 EDT

Contents:
  Re: Sorting associative arrays based on the value (Tom Christiansen)
  Re: Sorting associative arrays based on the value (Mark A Biggar)
  Re: question about perl patterns (Mark A Biggar)
  Re: Dynamic Loading for Perl (Eric Fifer)
  perl for OS/2 (Alexander A. Balke)
  Re: Building on SunOS 4.1.2 -- Core dump... (Walter Hunt)
  Perl for VMS (Mark A Biggar)
  more readable perl :-) (Tom Christiansen)
  SUMMARY: Sorting associative arrays based on the value (Shane Youl)
  program to make elm aliases.text into /usr/lib/aliases ? (Vincent D. Skahan)
  ObjOriented perl, dynamic Loading of C code for perl in tcl (Charles Thayer)

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

From: Tom Christiansen <tchrist@convex.COM>
Subject: Re: Sorting associative arrays based on the value
Date: Mon, 12 Oct 1992 16:45:22 GMT
Reply-To: tchrist@convex.COM (Tom Christiansen)

From the keyboard of tchrist@convex.COM (Tom Christiansen):
:Really long ago:
:
:    sub bynumvalue { $Table{$a} <=> $Table{$b}; } 

That should be "-" not "<=>" if it's really long ago.

--tom
-- 
    Tom Christiansen      tchrist@convex.com      convex!tchrist

Just remember: when you go to court, you are trusting your fate to
twelve people that weren't smart enough to get out of jury duty!

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

From: mab@wdl39.wdl.loral.com (Mark A Biggar)
Subject: Re: Sorting associative arrays based on the value
Date: Mon, 12 Oct 1992 17:17:25 GMT

In article <1992Oct12.082906.24636@mel.dit.csiro.au> sfy@koel.mel.dit.CSIRO.AU (Shane Youl) writes:
|This may be a FAQ, but then again...
|
|I have an associative array $Table{$Name} = $Number which I would like
|to sort by $Number. I have been converting the associative array into an
|ordinary two-d array and using the SUBROUTINE option to sort, but I
|thought that there might be a more elegant solution.

@keys = sort {$Table{$a} <=> $Table{$b}} keys(%Table);

@keys is now an array of keys sorted by $Number.

--
Perl's Maternal Uncle
Mark Biggar
mab@dl1.wdl.loral.com




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

From: mab@wdl39.wdl.loral.com (Mark A Biggar)
Subject: Re: question about perl patterns
Date: Mon, 12 Oct 1992 17:31:05 GMT

In article <kumar.718895215@phage.cshl.org> kumar@phage.cshl.org (Sanjay Kumar at Cold Spring Harbor Lab) writes:
|Is there an easy way to find the position of a regular expression
|match in a string?  I would like to do the equivalent of the
|index function, but use regular expressions rather than substrings.

Well you can say:

$str =~ /pattern/;
$substr = substr($str,length($`),length($&));

But it is usually much faster to just say:

$str =~ /pattern/;
$substr = $&;

or

$str =~ /(pattern)/;
$substr = $1;

When parsing up a string using RE's, it is almost always faster and easier
to use $`,$&,$' or () and $1,$2,... to decompose the string instead of using
character positions and substr.  Also if you're decomposing a string using known
positions and lengths, you should use unpack() instead of a sequence of
calls to substr or using wierd patterns like /(......)(.....)(......)/.

--
Perl's Maternal Uncle
Mark Biggar
mab@wdl1.wdl.loral.com


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

From: egf@pivot.sbi.com (Eric Fifer)
Subject: Re: Dynamic Loading for Perl
Date: 11 Oct 92 10:03:01 GMT

In article <9210080916.AA19163@isfrance.encore.fr>, kstock@isfrance.encore.fr (Kevin Stock) writes:
|
| This requires the dynload(3x) dynamic loading interface, but it could
| be a starting point for other implementations (for example, GNU's DLD).

I've done something similar with SunOS's dlopen(3x) routines.

Plus, I provided a mechanism that dynamically creates a stack frame
so that it can call most C and Fortran functions.  Only a pack style
description of the function parameters and return value is required.

The end result looks like:

	$dl_so = &dl_open("/lib/libc.so.1.6");
	die "$0: $dl_errstr" if($dl_errno);

	$dl_sub = &dl_sym($dl_so, "gethostname");
	die "$0: $dl_errstr" if($dl_errno);

	eval <<EOC;
		sub gethostname {
			&dl_call("$dl_sub", "+a i", "i", @_);
		}
	EOC

	@vals = &gethostname(' ' x 80, 80);
	print "@vals\n";

If there is interest I could clean it up and post it.  However, it is
SunOS (dlopen), SPARC (a couple of lines of assembler) and gcc (asm
extensions) specific.

--
Eric Fifer
Salomon Brothers Asia Limited
Urbannet Otemachi Bldg, 18th Fl
2-2, Otemachi 2-chome             | Internet: egf@sbi.com
Chiyoda-ku, Tokyo 100, Japan      | UUCP:     uunet!sbi!egf

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

Crossposted-To: comp.os.os2.apps
From: balke@maui.cs.ucla.edu (Alexander A. Balke)
Subject: perl for OS/2
Date: Mon, 12 Oct 92 19:02:59 GMT

I am trying to find a version of PERL for OS/2 which was compiled using 
the large memory model.  Any help would be appreciated.

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

From: walter@optimla.aimla.com (Walter Hunt)
Subject: Re: Building on SunOS 4.1.2 -- Core dump...
Reply-To: walter@optimla.aimla.com (Walter Hunt)
Date: Mon, 12 Oct 92 18:22:28 GMT

In article <1992Oct.103536.1394@abigale.uucp>, joel@abigale.uucp (Joel Rosi-Schwartz) writes:
|> In article <1992Oct8.183031.7429@peanuts.informatik.uni-tuebingen.de> jw@peanuts.informatik.uni-tuebingen.de (Joerg Wedeck) writes:
|> >In article <fritz.718476311@Cadence.COM>, fritz@Cadence.COM (Frederick Staats) writes:
|> >|> I've been trying to build perl-4.035 on a Sparc IPX with
|>  [ stuff deleted ]
|> >
|> >Try using gcc, I had the same problem under SunOS 4.1.3. When I used gcc
|> >everything worked fine (except 1 test).
|> 
|> I find this thread interesting and relevant to me at the moment.  I
|> am currently porting my application to Sun and it uses perl.  My
|> experience is exactly the opposite of what is stated above.  I tried
|> several times to build with gcc 2.2.2 and regardless of what I tried
|> (SysV/BSD universes for lib/includes, perl/Sun malloc, -O or no -O, -
|> static or using shared libs) I got the following test results (ok's
|> deleted):
|> 
|> 	op/eval........FAILED on test 0
|> 	op/regexp......FAILED on test 45
|> 	lib/big........ok
|> 	/bin/sh: 19198 Memory fault - core dumped
|> 
|> I finally gave up and compiled with Suns /usr/bin/cc and everything
|> work perfectly.  I will probably backtrack and try it with
|> /usr/5bin/cc and the SysV libs/includes, if I have the time before I
|> have to return the loaner machine.  The relevant details are:
|> 
|> 	SparcStation2 GX
|> 	SunOS: 4.1.2/5.0


	I was having the same problems. The fix was pointed out by
maplgrv!vid%astroatc.uucp@cs.wisc.edu (Dave Greunke). When doing the Configure
thing, DO NOT allow it to set your compiler flags to include /usr/ucb/include.
This will get defininitions for varargs which will make perl croak. I re-ran
Configure, with no -I flags in the compile flags, and got a properly working
version.

	Thanks also to uunet!antares.Tymnet.COM!mooring (Ed Mooring) and Mike
Stok <uunet!meiko.com!mike>, who sent me working config.sh files.


|> 
|> Cheers,
|> Joel
|> -- 
|>      ==================================================================
|>      ||               T E C H N E   R E S E A R C H                  ||
|>      ||  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  ||
|>      ||                     Joel Rosi-Schwartz                       ||
|>      ||   Hildorien House            +   Email: joel@abigale.UUCP    ||
|>      ||   12 Waverley Way            +    (pyrltd!abigale.UUCP!joel) ||
|>      ||   Finchampstead, Wokingham   +   Phone: +44 (734) 730.260    ||
|>      ||   Berkshire RG11 4YD (UK)    +   Fax:   +44 (734) 730.272    ||
|>      ==================================================================

-- 
Walter Hunt					walter@optimage.com
OptImage Interactive Services Company, L.P.	walter@aimla.com
11040 Santa Monica Blvd., Suite #300		uunet!{optimage,aimla}!walter
Los Angeles, Ca. 90025				(310) 445-5718

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

From: mab@wdl39.wdl.loral.com (Mark A Biggar)
Subject: Perl for VMS
Date: Mon, 12 Oct 1992 22:51:43 GMT


Does anyone have a perl for VMS that does not have the socket emulation
stuff linked into it.  The currently available VMS-perl via ftp does
have that stuff and won't run on a VMS machine that (stingy project) does
not have the emulation library installed.

--
Mark Biggar


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

From: tchrist@convex.com (Tom Christiansen)
Subject: more readable perl :-)
Date: Tue, 13 Oct 1992 00:10:20 GMT


I got tired of writing

    if (! &is_foobled($gnap)) 

and started writing 

    unless (&is_foobled($gnap)) 

but am now writing

    if (&isn't_foobled($gnap)) 

via this definition:

    sub isn't_foobled { !&is_foobled }

neat, eh? :-)

--tom
-- 
    Tom Christiansen      tchrist@convex.com      convex!tchrist
    "You can't have filenames longer than 14 chars.  
     You can't even think about them!"
        --Larry Wall in Configure from the perl distribution

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

From: sfy@koel.mel.dit.CSIRO.AU (Shane Youl)
Subject: SUMMARY: Sorting associative arrays based on the value
Date: Tue, 13 Oct 92 02:15:19 GMT

sfy@koel.mel.dit.CSIRO.AU (Shane Youl) writes:

|This may be a FAQ, but then again...

|I have an associative array $Table{$Name} = $Number which I would like
|to sort by $Number. I have been converting the associative array into an
|ordinary two-d array and using the SUBROUTINE option to sort, but I
|thought that there might be a more elegant solution.

Mike Stok <mike@meiko.com> writes:

|you can say something like

|foreach $key (sort {$Table{$a} <=> $Table{$b};} keys %Table)
|{
|  ....
|}

Thanks to those who responded -
Christopher Davis <ckd@eff.org>
Mike Stok <mike@meiko.com>
weingart@inf.ethz.ch
asherman@fmrco.com (Aaron Sherman)
przemek@rrdstrad.nist.gov (Przemek Klosowski)
--
  Shane Youl                                  ,-_|\    sfy@mel.dit.CSIRO.AU
  CSIRO Division of Information Technology   /CSIRO\   +61 3 282 2626
  723 Swanston Street Carlton 3053           \_,-._/
  AUSTRALIA                                       v    DoD#0504

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

From: vds7789@aw2.fsl.ca.boeing.com (Vincent D. Skahan)
Crossposted-To: comp.mail.elm
Subject: program to make elm aliases.text into /usr/lib/aliases ?
Date: 12 Oct 92 20:19:51 GMT

In the past, we've accumulated quite a large elm aliases.text
file that is installed as a global elm aliases file.  

Unfortunately, this file isn't worth a darn for people who 
aren't in 'elm'.  Is there a program somewhere to take an
elm 2.3-pl11 file and generate a /usr/lib/aliases file ?

any help is greatly appreciated...

-- 
   ---------   Vince Skahan   -------- vds7789@aw2.fsl.ca.boeing.com -------   

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

Crossposted-To: comp.lang.tcl
Date: Tue, 13 Oct 92 01:26:24 EDT
From: thayer@cs.columbia.edu (Charles Thayer)
Subject: ObjOriented perl, dynamic Loading of C code for perl in tcl

Such a short message, such confusion, oops... Here's a better explanation.

me> sub foo {
me>   local($a,$b,$c)=@_;
me>   print "$c\n";
me>   return ["$a $b"];
me> }

tc> Current thinking holds that ["$a $b"] would be a pointer to 
tc> a list containing one element, the string "$a $b", like
tc>     \( "$a $b" )
tc> or using the function=call syntax
tc>     ref ("$a $b")
tc> Although I get nervous about the function-call syntax.
tc> Let's see now, are you talking about 
tc>     &{$a}($b);
tc> That is, call the function whose name is in $a with the argument $b?
tc> How can you tell the name?

I was simply talking about &ref("$a $b"); which you mention first, not
the fancier &{$a}($b);  Here is the perl version:

$a="foo";
$b="bar";
["$a $b"];	==>  &ref('foo bar');
[$a $b];	==>  &ref('$a $b');

me> the '["$a $b"]' would call a user-written c-subroutine (see your usub
me> dir of the perl source.)

By this I simply mean you'd have the following code in 
perl/usub/moop.mus:

	moop_init()
	...
	    make_usub("moop", US_moop, usersub, filename);
	...
	usersub()
	...
	    switch (ix) {
	CASE char* moop
	I	char*		s
	END
	...

And in perl/usub/usersub.c:

	int userinit() { init_moop(); ...; }

moop() would be the implementation, in C, of &ref which you mention
above.  It's job is to provide a blunt entry point for arbitrary code
on the part of software toolers who write C code and recompile their
own versions of perl.  moop() is implemented in C and calls perl
routines by using the function callv() in perl/usub/usersub.c

[incidentally, do you have any sample code that uses callv(), or
callback()?  I have only been able to find mus examples.]

char *moop(char *s) is a very simple interface, in a little farther down
I will explain what I'd like it to do.

tc> Generalizing the dbm access routines so you could get at arbitrary 
tc> functions through associative arrays references is someone related
tc> to this.

I have no idea what you mean, but I did once try to write a small
object-oriented system for perl using strictly associative arrays as
symbol tables.  It was rudimentary but has helped me form to my
current opinions.  The methods in the system were simply strings that
got eval'ed if invoked on an object, and objects were stored in
another associative array.  The messaging routine was stored as a 
string also, so it was rewritable by objects themselves.  An object
could add a call to a trace function by changing the messaging
routine, or could install a messaging routine that would load a new
object table from disk into a new object associative array and then
start executing from the context of that object table.  And other
silly things that seemed fun at the time.

Now I am going into details again...so I'll leave that to another post.

me> And [["$a $b baz"] `ypmatch foo bar`] would do what you'd expect too.
tc> You mean this:
tc>   &{&{$a}($b,baz)}(`ypmatch foo bar`);

Here's a breakdown of what I intended to mean (with $a='tom',
$b='larry';) comments start with #:

	[["$a $b baz"] `ypmatch foo bar`];
		# expand the double quotes
==>	[['tom larry baz'] `ypmatch foo bar`];
		# run the back tick to generate a string
	[['tom larry baz'] 'yuck:0:0:super slug:/bin/slime'];
		# show how the inner squares are dealt with		
	[&moop('tom larry baz') 'yuck:0:0:super slug:/bin/slime'];
		# execute the inner squares and get result string
	['match "larry|baz"' 'yuck:0:0:super slug:/bin/slime'];
		# finish checking for a singly quoted string
	['match "larry|baz" yuck:0:0:super slug:/bin/slime'];
		# show how the outside squares are dealt with
	&moop('match "larry|baz" yuck:0:0:super slug:/bin/slime');
		# execute the outer squares and finally return a string
	'false';

me> it's syntactic sugar that makes perl look more like smalltalk.  
tc> People often want Perl to look more like other languages than Perl. :-)

The reason I say this is because I want it to be obvious that the
contents of the square braces are to be taken as a window onto
something outside of perl.  Something simpler might be where someone
implements their [] set to simply call a korn shell (a forced
example obviously, since this is easily done in perl):

	print ['for i in `ypcat ypservers`; do echo $i; done'];
==>	print &moop('for i in `ypcat ypservers`; do echo $i; done');
	print 'foo.cs.edu bar.cs.edu baz.cs.edu moo.cs.edu';

or if someone wrote an interface to snmp routines:
   print ['snmp_walk public myroot.enterprise.cisco.arp-cache foo.cs.edu'];

or if someone wrote an interface to their favorite sql server:
   @match=split(/:/, ["select (*) where $foo sounds like $bar in $table"]);

of if someone wrote an interface to curses:
   ['wmvaddstr' ["newwin $height $width named banner"] " $x $y $title"];

me> I would like to see tcl used as a front-end to the suggested '[]'
me> syntax.  The reason is that tcl is a very reasonable, small, embedded
me> command language, which could be easily put in any C program.  There
me> are already tcl/sybase/curses/xwindows/motif/oracle/snmp/...
me> combinations out there.  If these tools were all talking to each other
me> with the tcl-send command I could stop worrying about which toolchest
me> to use when tackling something, since they would already work
me> together.

tc> I'm don't see what using tcl instead of a Perl version of these
tc> things would buy you.  

Imagine the scenario where you have a small embeddable command
language such as TCL (tool command language) or SIOD (scheme in one
defun) and a larger far more powerful programming tool, PERL.

(1) First consider the result of adding this command interpreter to perl
just for the purpose of implementing an object-oriented messaging and
inheritance system.  To perl you add &moop() to properly call the 
the embedded command language, and to the embedded command language
you add a new built-in that can call a perl-eval with an arbitrary
string.  Then you write your simple object-oriented system either in
a few low-level C additions to the embedded command language or in
the command language itself.

In particular TCL has support in TK, the x-windows based tcl for a
simple object-construction system to build window-widgets.  SIOD,
which is a tiny version of scheme can support closures and is capable
of running a small object-system written in scheme (although I don't
like the idea of having garbage collection running for a simple
backend.)

This is good because you haven't really gone and added to perl yet you
have an object-oriented perl whose object system is flexible and small
but very general.  Their is little to worry about for forward
compatibility, eg. issues of associative arrays being bigger or
packages holding more complicated state.  Nothing to slow your
favorite old perl down if your not using the object system.

(2) Secondly.  And this is the part that actually interests me...
(mostly as an enigma) Now, imagine that someone has also added an
embedded command interpreter to another of your favorite tools, say a
library of snmp routines, as well as to your favorite sql-capable
database.  And furthermore, your command-interpreter has a `send
command' that allows one command-interpreter to ask another
command-interpreter to execute an arbitrary command.

Now you can write a perl script that sits around checking the load
on another machine, and when that machine starts getting overloaded
your perl script asks the snmp routines what is going on with all
your routers then formats the information and dumps it to the sql
database:

	#!/bin/perl
	INIT: ...
	print 'Just another perl-base sys-admin.';
	while(1) {
	  &dump_routes(`ypmatch routers netgroup`) 
	    if &rup('danger-mouse') > 10;
	  print '.';
       	  sleep(60 * 60 * 60);
	}
	sub dump_routes() {
   	  local($router);
	  while($router = shift @_) {
	    print TMP_FIFO ["send snmp local snmpget ...arp-cache $router"];
	    ...
	    ["send sql local $parsed_arp_cache"];
	  }
	  1;
	}

If you've got the object system running however this might look more like:

	#!/bin/perl
	INIT: ... [inherit sqldb from postgres, sqlcmds] [new sql sqldb]
	print 'Just another perl-base sys-admin.';
	while(1) {
	  [sql.store local ['snmp.routes {' `ypmatch routers netgroup` '}']]
	    if ['info.rup danger-mouse > 10'];
	  print '.';
       	  sleep(60 * 60 * 60);
	}

and suppose that the snmp package is actually another perl script you
wrote for talking to "snmp/udp"  :)

This is good because you can build tools that are more and more
reusable, each with a well defined interface.  And you're not limited
to perl per say, because someone else working down the hall can
implement his database system in C using Postgres, and another person
can write a network object manager in C++.  And what's even better is
that you can do all your report generating and queries in Perl since
your tool is independent of theirs.  Also the object manager can talk
to the database with the same freedom.  With something like tcl you
could also have a graphic front-end to this conglomeration of tools
that the user can reconfigure with tcl commands, so that if they want
to change menu ordering or which tables go in which part of the window
its all very easy.

me> -Someone's already written a dld based dynamic object loader in tcl.
me> -There are versions of tcl that already dynamically load missing
me> symbols.

tc> And someone -- Kevin Stock in 9210080916.AA19163@isfrance.encore.fr> --
tc> last week posted an way to dynamic load C functions from perl.

Yes, but I think that one used dynaload, the tcl one use dld from gnu.
But that's not the point that I hoped to make, which is that someone
wrote a dynamic loader tool for one or the other (tcl or perl)
already.  It shouldn't be necessary to rewrite another.  (this is a
bad example because dynamic loading is not so straight-forward a
matter --eg. it is probably necessary for the process who will use the
library to actually load it.)

me> -Someone's already written a sybased tcl.
tc> And a sybased (etc.) perl.

Yes, the list of things I mentioned was meant to be a list of things
that I think have been already in both perl and tcl (I'm not sure
about a few.)  If these could be integrated it would save the trouble
of having the two communities of tcl users and perl users each hack-up
up their nice tools (syb_perl, and syb_tcl) and it would save 
much duplication efforts.

If there were a version of sybase that talked tcl and supported a
send command all versions of perl (not syb_perl) and tcl (not syb_tcl)
could use the database.

me> -Tcl could implement struct for perl.

tc> Struct is an interesting problem, and I'm certainly not entirely
tc> satisfied with the c2ph approach, but I don't see why that requires
tc> a hybrid language, which is what I hear you asking for.

Well, I'm really advocating a simple but flexible form of intra-tool
communication, based on the merging of two good tools in a manner that
is suitable for their original design intention.  A clear and simple
emulation of structs might be an added benefit.

me> -We could get rid of some of the features already in perl.
tc> I don't think you'll make a lot of friends by removing features,
tc> since most have their champions.  Did you have any candidates for 
tc> deletion?

I don't really desire deleting anything from perl, the idea behind
that statement is to make you think ``Gee, if I were going to delete
something from perl what would it be?''  Then to think ``What do these
two things have in common, and how can I factor this out so that they
can share it, and better yet, some else could use it too.''

/charles
PS.  "wafe" is great idea.
PPS.  Just another perl hacker (Here's the key to using assoc. arrays for 
object systems):

# Takes a string and returns a reference to the variables of that
# name.  Used primary to access an associative array by string.
# Eg. local(*tab) = name2table("assoc_array"); $tab{'foo'}='bar';

sub name2table {
    local($name)=$_[0];
    eval("*$name");
}

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

** FOR YOUR REFERENCE **

The service addresses, to which questions about the list itself and requests
to be added to or deleted from it should be directed, are as follows:

    Internet: Perl-Users-Request@fuggles.acc.Virginia.EDU
              Perl-Users-Request@uvaarpa.Virginia.EDU
    BITNET:   Perl-Req@Virginia
    UUCP:     ...!uunet!virginia!perl-users-request

You can send mail to the entire list (and comp.lang.perl) via one of these
addresses:

    Internet: Perl-Users@uvaarpa.Virginia.EDU
    BITNET:   Perl@Virginia
    UUCP:     ...!uunet!virginia!perl-users

End of Perl-Users Digest
******************************