HDTenEightyP/NetNews huggingface dataset:
From: good@gdwest.gd.com (David L. Good)
Subject: Re: perl script wanted for word manipulation
Keywords: word alphabetization, letter count
Organization: General Dynamics Corp.
Date: Fri, 25 Sep 1992 21:06:33 GMT

In article <1992Sep23.195109.2534@vela.acs.oakland.edu> jafortun@vela.acs.oakland.edu (James Fortune) writes:
>I have a file with english words one to a line.  What I would like to
>do is write to standard output a file that repeats the word, prints out
>(after a space) the number of letters in the word, then after another
>space prints the alphabetized version of that word.  This is a real
>application (I play Scrabble).  Is there an easy way to do this using
>perl?
>
>E.g.,
>
>bombastic
>
>produces
>
>bombastic 9 abbcimost
>

How about:

perl -nle 'print "$_ ", length, " ", sort(split(//));'

Is that easy enough? :-)

-- 
David Good                                               good@gdwest.gd.com

                 This space intentionally left blank.
Newsgroups: comp.lang.perl
From: jamie@heavy.enet.dec.com (Jamie.)
Subject: Re: Docs for PERL Needed.
Reply-To: jamie@heavy.enet.dec.com (Jamie.)
Organization: Digital Equipment Corporation
Date: Mon, 28 Sep 1992 08:58:02 GMT


Not much help, I'm afraid, but I'm in much the same position as yourself;
trying
to find out about Perl without much in the way of documentation...

In the UK, there are no Perl textbooks in print, so I can't get anything 
"official" so I've gathered what I can.

So far, I have the man pages, the Perl Postscript Reference posted to
alt.sources
or similar just recently, and a set of three Perl articles from Aug-Sep 91
Unix World. I'd really recommend the articles to anyone with no textbooks
available... I'm at least picking up something from them.

If there's anything else that's publicly available on the net that I can
learn from, I'd appreciate a pointer.

Also, is there a source repository that I might access to learn by example
from?

Thanks,

				Jamie.
Newsgroups: comp.lang.perl
From: wescott@grok67.ColumbiaSC.NCR.COM (Mike.Wescott)
Subject: bug, porting problem, or pilot error?
Organization: "NCR Corp, Columbia, SC"
Date: Mon, 28 Sep 92 18:58:56 GMT

The following causes perl to dump core:

	$fin = "/dev/zero";

	open(FIN, $fin) || die "can't open $fin\n";

	$i = 0;
	$r = sysread(FIN, $mpinfo[$i], 169);
	print $r,"\n";

If the read length is made small enough, core dumps stop.
Is an undefined indexed variable not permitted as an argument
to read or sysread? Or have I screwed up the port?
-- 
	-Mike Wescott
	 mike.wescott@ColumbiaSC.NCR.COM
Newsgroups: comp.lang.perl,gnu.emacs.sources
From: peta@thunder.mcrcim.mcgill.edu (Peter Whaite)
Subject: Re: Perl, Emacs, and she-bang line.
Organization: McGill Research Centre for Intelligent Machines
Date: Mon, 28 Sep 92 01:49:49 GMT

In article <Bv9KE9.124@mtholyoke.edu> jbotz@mtholyoke.edu (Jurgen Botz) writes:
>In article <1992Sep23.215458.26601@thunder.mcrcim.mcgill.edu> peta@thunder.mcrcim.mcgill.edu (Peter Whaite) writes:
>>Or you can use as the first line
>>
>>	#!/usr/bin/perl -- # -*- Perl -*-
>
>Is this supposed to work in general?  I couldn't find any reference to
>"--" in the Camel book, and I just (today!) has an odd problem with this
>usage.  Specifically, a script I wrote that had that identical line as
>its first line crapped out with "while: expression syntax".  Once I removed
>everything after the "#!/usr/bin/perl" it worked.  I had a hell of a time
>figuring out what was going on, too... it really bothered me when the
>thing ran just fine under the perl debugger and died when I ran it from
>the shell.  Finally realized what was going on when I tried running it
>with other perl options by typing "perl -w myscript" and it always worked.

I've had mail and there have been followup postings you must have missed.
Only the first 32 characters of the first line of the script file count (see
execve(2)) but on some systems when there are more than 32 chars (eg ULTRIX)
weird things happen.  Thus even though this technique always worked for me on
SunOS 4 and on IRIX its probably not a good idea in general.  Setting the mode
using buffer local variables is preferable.



Newsgroups: comp.lang.perl
From: evans@zk3.dec.com (Marc Evans)
Subject: Re: Perl & the new DEC Alpha machines running OSF1
Keywords: dec_osf1.sh
Reply-To: evans@zk3.dec.com
Organization: Digital Equipment Corporation - Nashua, NH
Date: Tue, 6 Oct 1992 11:13:42 GMT

|> I've successfully installed Perl on an OSF1/mips machine.  But soon my development
|> environment will be changing underneath me.  We're getting the new DEC Alpha
|> machines running OSF1.  Question is, do I need to wait for a new hints file before
|> I can port Perl to that platform?  Or will the OSF1 hints files be sufficient?

You should be able to use the enclosed hints file for both MIPS and ALPHA
flavors of DEC OSF/1. I have successfully used it on both running version
1.2 of the OS. Configure figures out the rest of the answers pretty well.
I should note that the reason for defining "libc" is because Configure does
seem to have a problem extracting the symbol list from the archive form of
the library (I don't think it can figure out how to grop the output of nm).

cat <<FOOBAR >hints/dec_osf1.sh
d_crypt='undef'             # The function is there, but it is empty
d_odbm='undef'              # We don't need both odbm and ndbm
gidtype='gid_t'
groupstype='int'
libpth="$libpth /usr/shlib" # Use the shared libraries if possible
libc='/usr/shlib/libc.so'   # The archive version is /lib/libc.a
case `uname -m` in
    mips|alpha)   optimize="$optimize -O2 -Olimit 2900"
                  ccflags="$ccflags -std1 -D_BSD" ;;
    *)            ccflags="$ccflags -D_BSD" ;;
esac
FOOBAR

- Marc
Newsgroups: comp.lang.perl,comp.unix.admin
From: jfriedl+@CS.CMU.EDU (Jeffrey Friedl)
Subject: Re: Why I am glad I know perl
Reply-To: jfriedl@cs.cmu.edu
Organization: Carnegie Mellon / Omron Corporation
Date: Tue, 6 Oct 1992 17:14:18 GMT

ehrlich@colossus.cs.psu.edu (Dan Ehrlich) writes:
|> Here is just one reason why every system administrator should know perl.
|>  [.....]
|>            Use echo to construct a script that will set execute bits on
|>            sh, tar, cat, ls.
|>  [.....]

|> Note that this would not work on a Sun as /bin is a link to /usr/bin and
|> ftp would have vanished along with everything else.  

But in that case, you'd just use echo to construct a perl script that
mimics ftp (-:
From: merlyn@ora.com (Randal L. Schwartz)
Newsgroups: comp.lang.perl
Subject: Re: "Camel" book
Date: 2 Oct 92 05:54:40 GMT
Article-I.D.: romulus.MERLYN.92Oct1225434
	<1992Oct1.222219.16922@grouper.mkt.csd.harris.com>
Organization: Stonehenge Consulting Services; Portland, Oregon, USA

In article <1992Oct1.222219.16922@grouper.mkt.csd.harris.com> wdh@grouper.mkt.csd.harris.com (W. David Higgins) writes:
   Does having the first printing give one special powers unknown to
   mortal man?  If so, why hasn't it rubbed off on me ;-)

No, but it means you're a Perl "old timer". :-)

   What is the current printing, anyway?

Third.  With any luck, the next printing will describe Perl 5.0, if
not at least 4.035 :-).  But there won't be any text updates before at
least February at this rate.  I think I'd know if there were.  So
you'll get a good six months use out of your books before you have to
trade them in because the pages are falling out.

print "Just another Perl [book] hacker,"
--
Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
merlyn@reed.edu (guest account) merlyn@ora.com (better for permanent record)
cute quote: "Welcome to Portland, Oregon -- home of the California Raisins!"
From: ovhe@ki.icl.se (Ove Hedin)
Newsgroups: comp.lang.perl
Subject: Where to find a compiled perl for SCO Unix ??
Keywords: sco,sysv32
Date: 28 Sep 92 19:40:54 GMT
Organization: ICL Data AB, Sweden

Hi

I would be be very happy if somebody could tell me where to
find a compiled perl 4.x , or maybe mail me a uudecode'ed one !!

Thanks


--
-- * All opinions and questions are my own -----------------------------------
Ove Hedin  Phone +46 (0)31499376 , DOMAIN Address : ovhe@ki.icl.se
X400: I=O ; S=Hedin ; OU1=SWE4701 ; O=ICL Data ; P=ICL ; A=TEDE ; C=SE
From: chare@unilabs.uucp (Chris Hare)
Newsgroups: comp.lang.perl
Subject: localinzing file handles
Date: 4 Oct 92 13:50:19 GMT
Organization: UniLabs Research Group

I'm working on a script which will recursively read through other scripts.
I need to be able to set a file handle as local to the instance of the
subroutine being worked through.

How do I do this?

Thanks!
-- 
????                --- It Always works for me! ---                           
Chris Hare, UNIX Scientist                  Preferred : chare@unilabs.uucp
Just a mild-mannered consultant by day ....
From: ben@ronin.UUCP (Uncle Dragon at ronin)
Newsgroups: comp.lang.perl
Subject: Re: How to convice awk/sed users to use Perl ?
Date: 6 Oct 92 01:08:39 GMT
Organization: Ronin House


My arguments for using perl come from the kinds of applications that I put
these utilities to: testing and generating reports as well as converting
from one typesetting ruleset to another. I have found that I inevetably have
had to use a combination of sh, sed, and a lot of awk to accomplish most of
these tasks. It is so much easier to have only one script in one language 
that does what all of these others do. And perl scripts are faster, if
for no other reason than they don't have to create so many new and separate
processes.
-- 
\^___^/   ===================================================    
 (o o)    Uncle Dragon: ben@ronin.UUCP || ben@bytepb.byte.com     
  \|/     Peterborough, New Hampshire        Live Free or Die
   m      ===================================================
Newsgroups: comp.lang.perl
From: Tom Christiansen <tchrist@convex.COM>
Subject: Re: What is a true value ?
Originator: tchrist@pixel.convex.com
Date: Wed, 30 Sep 1992 18:40:57 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):
:You need to put
:    1;
:at the end to tell Perl that the 'require' succeeded.

Yes, convention uses a 1, but any one of the infinite flavors 
of truth in Perl would also be acceptable.

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

    If the code and the comments disagree, then both are probably wrong.
                    -- Norm Schryer
Newsgroups: comp.lang.perl
From: mike@meiko.com (Mike Stok)
Subject: Re: Perl program grows in size
Organization: Meiko Scientific Corp.
Date: Thu, 1 Oct 1992 11:44:47 GMT

In article <lckmieINNnof@ozona.cs.utexas.edu> jefftep@cs.utexas.edu (Jeffrey Grills) writes:
>
> tom christiansen writes:
> >
> >Look for any local()s.  [...]
> >which as currently implemented will cause an apparent memory leak.
> >
> >--tom
>
>
>Any local?  Or just in a loop?  Isn't using local() the prefered way
>of passing parameters?  Doesn't make sense that this useful construct
>for keeping your program sane is faulty in this manner.  The only
>alternative I see for being reasonable is excessive use of packages.
>Maybe prefix every local with subroutinename'?

I think that what happens in a 

for (;;)
{
  local ($banana);
  ...
}

is that a "new" local copy of $banana is created each time around the
loop, and all of them get freed up when they go out of scope (i.e.
when the loop is exited).  This is because local happens at run time
saying "give me a new $banana in this scope" rather then at "compile"
time as a directive to reserve some space on the stack, once you get
this distinction everything becomes clear (well, it did for me, after
a few days of scratching my head... :-)

The way to emulate some awful compiled language like C++ which lets
you sling in declarations anywhere is to add a block like

{
  local ($banana);

  for (;;)
  {
    ...
  }
}

which stops the local being executed every time around the loop and
eating memory.

I usually put locals at the top of subroutines (so you can see what is
being hidden in that scope at a glance) or at the top of non-loop
blocks (e.g. just after an if or else etc.), but I always try and
group them together for ease of checking what I got wrong this time
;-)

Mike
--
The "usual disclaimers" apply.    |
Mike Stok                         |
mike@meiko.com                    |
Meiko tel: (617) 890 7676         |
Newsgroups: comp.lang.perl
From: asherman@laser.fmrco.com (Aaron Sherman)
Subject: Re: question of building array of arrays
Reply-To: asherman@fmrco.COM
Organization: I-Kinetics, 19 Bishop-Allen Dr., Cambridge, MA
Date: Sun, 27 Sep 1992 21:54:52 GMT

>>>>> kc@hpscit.sc.hp.com (Kwok Cheung) said:

kc> My code look something like this
kc> #!/usr/bin/perl
kc> open(FOOD,food)
kc> || die "can't open food"'
kc> while ($lines=<FOOD>) {
kc>    ($head, $tail)=split(' ',$lines);
kc>    push(@{$head},$tail);
kc>    print "list for $head is @{$head}","\n";
kc> }

open(FOOD,'food') || die("Cannot open food: $!\n");
while(<FOOD>)
{
	($head,$tail) = split(/\s+/,$_,2);
	eval("push(\@$head , \$tail);");
}

kc> 3. Eventually I want to build an array call @food that have "meat","fruit","vegetable"
kc>    Can I do it in perl ? 

push(@food,$head);

At the end you could do the following:

foreach(@food)
{
	*array = $_;

	print "Foods of class \"$_\":\n\t", join(', ',@array), "\n";
}

That should work just fine (though I have not tested this code, so it is
possible that there are typos).


			-AJS

--
--------
Disclaimer: I am solely responsible for the content of this message.
The views expressed here may not be the views of I-Kinetics, Fidelity,
any of the Fidelity-owned corporations or my mother.
From: rindress@ctron.com (Rindress MacDonald)
Newsgroups: comp.lang.perl
Subject: A C++ class lister..?
Date: 30 Sep 92 14:04:04 GMT
Reply-To: rindress@ctron.com (Rindress MacDonald)
Organization: Cabletron Systems Inc



  Hi,
    I was wondering if anybody has a perl script that will take C++ style
  and extract information such as what classes are defined in what files,
  what functions are called from what methods, etc.  Sorry if this has been
  asked before but I haven't seen it in the FAQ.  If nobody has it, would
  anybody care to share their opinion of how difficult it would be to build
  such a beast.  I have in mind something like ctags for C++ code.  Well
  any pointers would be greatfully appreciated.


  Thanks in advance,
  Rindress


------------------------------------------------------------------------------
                   Name: Rindress MacDonald
                  Email: rindress@ctron.com
                Company: Intuitive Graphical Solutions 
        
    Disclaimer:  The opinions expressed here are that of IGS (me) and not of
                 Cabletron Systems.
------------------------------------------------------------------------------
From: barmar@think.com (Barry Margolin)
Newsgroups: comp.lang.clos
Subject: Re: class variables
Date: 1 Oct 1992 14:50:18 GMT
Organization: Thinking Machines Corporation, Cambridge MA, USA
NNTP-Posting-Host: telecaster.think.com

In article <1992Oct1.071605.8674@cs.ucla.edu> lange@lanai.cs.ucla.edu (Trent Lange) writes:
>I have to agree with this.  Though the current :allocation :class option
>is certainly more useful than defvar (as Barry points out), it would be
>*very* useful if there was an slot :allocation option that allocated
>:class-like slots per subclass -- maybe an option called :class-class
>or something.  

I'd call it something like :PER-CLASS.

>It would definitely add functionality to CLOS, and in a very intuitive way,
>so that (setf (slot-value (class-prototype classA) 'class-class-slot) X)
>would set the slot-values of all instances of classA to X, without
>changing the slot-values of instances of other classes.

I don't think it really adds that much functionality.  It's relatively
straightforward to implement using existing CLOS facilities, not even MOP.

(defclass per-class-slot-mixin ()
  (value-table :allocation :class :initform '() :accessor value-table))

(defmethod per-class-slot-value ((self per-class-slot-mixin) (name symbol))
  (let* ((class-table (assoc (class-of self) (value-table self)))
	 (value-entry (assoc name (cdr class-table))))
    (if value-entry
	(cdr value-entry)
	(error ...))))

(defmethod (setf per-class-slot-value) (new-value (self per-class-slot-mixin) (name symbol))
  (let ((class-table (assoc (class-of self) (value-table self))))
    (unless class-table
      (setf class-table (cons (class-of self) nil))
      (push class-table (value-table self)))
    (let ((value-entry (assoc name (cdr class-table))))
      (if value-entry
	  (setf (cdr value-entry) new-value)
          (push (cons name new-value) (cdr value-entry))))))

By using MOP you should be able to make this accessible using ordinary
SLOT-VALUE.  But since most slot access should be done via accessor
methods, I don't really see the need for this, as use of
PER-CLASS-SLOT-VALUE could be hidden inside the accessors:

(defmethod foo-slot ((self foo))
  (per-class-slot-value self 'slot))

(defmethod (sef foo-slot) (new-value (self foo))
  (setf (per-class-slot-value self 'slot) new-value))

If you find this tedious, hide it in a macro.

>Is this the kind of thing that might be put up for review in the proposed
>dpANS Common Lisp standard?

You can suggest anything you want in your review comments, and this is
certainly the kind of thing that's appropriate.
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

barmar@think.com          {uunet,harvard}!think!barmar
Newsgroups: comp.lang.clos
From: cb@maths.bath.ac.UK
Subject: Re: Built-in functions (was Re: Beginner's Question - CLOS)
Organization: The Ohio State University Department of Computer and Information Science
Date: Tue, 6 Oct 1992 10:35:37 GMT





>3. Neither 1 nor 2 is in any way an argument that compiled Lisp is
>always as fast as hand-coded assembler.  They're not even an argument
>that compiled Lisp is as fast as C.

That's my point though.  I'm convinced that a competant C or assembly
language programmer can code builtin functions that will be 
faster than if they were Lisp coded.

>4. Nonetheless, there are cases where Lisp is as fast, or faster 
>than, C.  There are also times when compiled code is faster than
>hand-coded assembler.  (Indeed, not all assembly code is designed
>for max speed; sometimes readability considerations intervene.)

Well, I've never seen it.  Whenever I C code stuff and interface it
to Lisp, it runs many times faster.  I've C coded 80% of my
Petri-net simulator and interaced it so it can be executed from
EuLisp and it's almost 8 times faster than the pure CMU common lisp
version (and it's not like I'm the worlds hottest C programmer).  Also
note that pure Eulisp is slower than CMU Common Lisp.

>
>HCL is a very fast (on sun3's) lisp and part of the reason is
>that much of it is written in assembly language.

>Is it faster than other Lisps?  How much faster?  Is it faster
>than C?

4 years ago HCL ran the Gabriel Benchmarks faster than KCL, AKCL,
and ALLEGRO on SUN3's.  It runs tak about as fast as C, but he cheated
on that one.  It was designed to run the Gabriel Benchmarks fast, but
it's not really useable for anything other than that.
The port to SUN4's is pretty lame though.
Since so much of it is written in assembly language it doesn't port
well.
From: barmar@think.com (Barry Margolin)
Newsgroups: comp.lang.clos
Subject: Re: class variables
Date: 30 Sep 1992 19:58:46 GMT
Organization: Thinking Machines Corporation, Cambridge MA, USA
NNTP-Posting-Host: telecaster.think.com

In article <CUTTING.92Sep30102223@skye.parc.xerox.com> cutting@skye.parc.xerox.com (Doug Cutting) writes:
>As it stands, class allocation approximates DEFVAR.

Except that the user of the slot doesn't have to know whether it's a
per-instance or a per-class variable.

For instance, you can have a class slot that's overridden by an instance
slot in a subclass.  For instance:

(defclass elephant ()
  (color :reader elephant-color
	 :allocation :class
	 :initform 'grey))

(defclass painted-elephant (elephant)
  (color :allocation :instance
	 :initarg :color
	 :writer (setf elephant-color)))

or vice versa:

(defclass bear ()
  (color :accessor bear-color
	 :initarg :color))

(defclass polar-bear ()
  (color :allocation :class
	 :initform 'white))

(defmethod (setf bear-color) (color (self polar-bear))
  (unless (eq color 'white)
    (error ...)))

-- 
Barry Margolin
System Manager, Thinking Machines Corp.

barmar@think.com          {uunet,harvard}!think!barmar
Newsgroups: comp.lang.clos
From: jonl%kuwait@lucid.com (Jon L White)
Subject: Finding valid initargs to MAKE-INSTANCE
Organization: The Ohio State University Department of Computer and Information Science
Date: Fri, 2 Oct 1992 04:58:56 GMT

re: How can I determine whether a given implementation supports the (MOPish) 
    :NAME and :DIRECT-SUPERCLASSES initargs on the applicable MAKE-INSTANCE 
    method? I'm using Lucid 4.0.2--which BTW doesn't seem to support any 
    initargs on the method applicable to the example above. 

Lucid 4.0 release was composed shortly after the acceptance by X3J13
of the CLOS proposal, and supports primarily the interfaces listed 
therein (i.e., virtually none of the "creation" MOP, althoug it does
support the "introspective" part).   Lucid 4.1 -- which is at this
very moment finishing Beta testing and preparing for first real shipments
on the SPARC -- has exactly what you want, as documented in AMOP.


On a side note, regarding Gregor's advice for "Snooping about":

    Use compute-applicable-methods, class-prototype and method-lambda-list
    to figure out what keywords all the methods accept.  . . . 

I think 'function-keywords' might be the better function to use than
'method-lambda-list'.  Furthermore, you would have to look not only
at the MAKE-INSTANCE methods, but on the whole set of methods involved
in the creation "protocol"; for a call to MAKE-INSTANCE, this involves:

  MAKE-INSTANCE, ALLOCATE-INSTANCE, INITIALIZE-INSTANCE, SHARED-INITIALIZE



-- JonL --
Newsgroups: comp.lang.clos
From: gregor@parc.xerox.com (Gregor Kiczales)
Subject: Re: Finding valid initargs to MAKE-INSTANCE
Organization: Xerox Palo Alto Research Center
Distribution: all
Date: 28 Sep 92 11:46:26



   From: charest@Aig.Jpl.Nasa.Gov (Len Charest)
   Date: Fri, 25 Sep 1992 22:41:27 GMT

   How do I determine the valid initargs for a method on MAKE-INSTANCE?
   For example, when programmatically creating a class:

   (make-instance 'standard-class
		  :name 'green
		  :direct-superclasses (mapcar #'find-class '(yellow blue)))

   How can I determine whether a given implementation supports the
   (MOPish) :NAME and :DIRECT-SUPERCLASSES initargs...

I think this piece of code should be easy to write with the MOP.

Use compute-applicable-methods, class-prototype and method-lambda-list
to figure out what keywords all the methods accept.  (Actually, it might
be good to split this out as a seperate operation that works on any
generic function, or list of methods.)  Then use class-slots and
slot-definition-initargs to figure out what slot filling initargs the
standard method on shared-initialize accepts.

You should actually be able to figure out what you want to know this
way.  If you can't, that may say something about the initialization
protocol.

Gregor
Newsgroups: comp.lang.clos