HDTenEightyP/NetNews huggingface dataset:
From: dov@menora.weizmann.ac.il (Dov Grobgeld)
Newsgroups: comp.lang.perl
Subject: quoteSplit - Split string into array with embedded quotes
Date: 4 Sep 92 08:54:40 GMT
Reply-To: dov@menora.weizmann.ac.il
Organization: The Internet

Here is a small useful subroutine I put together. It has probably been
done before, and it has probably been posted as well. But as has been said
before here, it is easier to reinvent the wheel in Perl, than to go to the
junk yard looking for an old one. There is a nice use of m//g in the
script, and a blasting one-liner, which to the uninitiated certainly
would look like line-noise.

Enjoy!


#############################################################################
#  quoteSplit. Splits a text string into an array and allows for embedded
#  quoted strings.
#
#  Examples (perl quoting mechanism q() used to denote input strings...)
#
#     q(a b c)  splits into ('a','b','c')
#     q(ab,c,d) splits into ('ab','c','d')
#     q('a b' c) splits into ('a b', c)
#     q('that\'s', "it ") splits into ("that's", "it")
#
#  Dov Grobgeld
#  The Weizmann Institute of Science, Israel
#  Email: dov@menora.weizmann.ac.il
#############################################################################

sub quoteSplit {
    local($_) = $_[0];
#    local(@list);

    s/\\"/\01/g; s/\\'/\02/g;   # Hide escaped quotation marks

#    @list= /"[^"]*"|'[^']*'|[^\s,]+/g;
#    grep(s/^(["'])(.*)\1$/$2/ + tr/\1\2/"'/, @list);
#    @list;

    # This one liner is equivalent to the the three lines above
    grep(1+s/^(["'])(.*)\1$/$2/+tr/\01\02/"'/,/"[^"]*"|'[^']*'|[^\s,]+/g);
}

while(<>) {
    print join(":", &quoteSplit($_)),"\n";
}

--
                                                        ___   ___
                                                      /  o  \   o \
Dov Grobgeld                                         ( o  o  ) o   |
The Weizmann Institute of Science, Israel             \  o  /o  o /
"Where the tree of wisdom carries oranges"              | |   | |
                                                       _| |_ _| |_
                                       
Newsgroups: comp.lang.perl
From: mike@meiko.com (Mike Stok)
Subject: Camel Book for 5.xxx hardback?
Organization: Meiko Scientific Corp.
Date: Sat, 29 Aug 1992 16:21:51 GMT

If there's going to be a new Camel Book for the new Perl, will it ever
be available as a hardback?  Of all the books on my shelf the Camel
Book is the most heavily used (with the possible exception of
Peopleware which is rarely on the shelf :-) and although it's only 18
months old it's showing quite a few signs of wear and tear.  How many
people out there would be interested in shelling out extra money for a
more durable book?

Just wondering

Mike
--
The "usual disclaimers" apply.    | ... many were weak and confused, succumbing
Mike Stok                         | to drink or drugs whenever possible ...
mike@meiko.com                    |
Meiko tel: (617) 890 7676         |                          Hunter S. Thompson
From: ram@eiffel.com (Raphael Manfredi)
Newsgroups: comp.lang.perl
Subject: Re: Using $*, but pattern doesn't match
Date: 25 Aug 92 20:40:14 GMT
Organization: Interactive Software Engineering, Santa Barbara CA

Quoting rray@lookout.it.uswc.uswest.com (Randy J. Ray) from comp.lang.perl:
>I thought that ".* would match anything (up to a final ")" in this case)
>with $* set to 1?

Reading The Fabulous Manpage:

"Regular Expressions
	[...]
	To facilitate multi-line substitutions, the . character
	never matches a newline (even when $* is 0).  In particular,
	the following leaves a newline on the $_ string:

		$_ = <STDIN>;
		s/.*(some_string).*/$1/;
"

You have to use [.\n] if you want to match anything.
-- 
Raphael Manfredi <ram@eiffel.com>
Interactive Software Engineering Inc.
270 Storke Road, Suite #7                      / Tel +1 (805) 685-1006 \
Goleta, California 93117, USA                  \ Fax +1 (805) 685-6869 /
Newsgroups: comp.lang.perl
From: hanusj@bionette.CGRB.ORST.EDU (Joe Hanus)
Subject: Re: Help with variable interpolation inside s///
Keywords: variable interpolation, substitution
Organization: Biological Computing Consortium, OSU, Corvallis, OR.
Date: Wed, 2 Sep 1992 21:22:46 GMT

In article <1992Aug28.182857.9674@netlabs.com> lwall@netlabs.com (Larry Wall) writes:
>In article <1992Aug27.203737.13356@CS.ORST.EDU> hanusj@storm.CS.ORST.EDU (Joe Hanus) writes:
>:       s/$word/$word/gi;   # this is the line that's not working.
>:       # It should find the word in $word regardless of case and 
>:       # substitute the word in $word as it was located in the 
>:       # dictionary
>
>I suspect you're running 4.019 or earlier-since this was supposedly fixed in
>patch 20.  We're now at 4.035.
>
>Larry


We are running perl version 4.035.  To verify this I ran
/usr/bin/perl -v.  Any other suggestions?


joe
hanusj@storm.cs.orst.edu
Newsgroups: comp.lang.perl
From: sandyb@world.std.com (Sandy Bendremer)
Subject: Data Entry / Database routines for perl
Summary: Looking for data entry and database perl routines
Keywords: perl database entry
Organization: AnyWare Associates -- Boston, MA
Date: Mon, 31 Aug 1992 00:49:22 GMT

Has anyone put together a library of perl routines for data entry and/or
basic database manipulation??  Any good examples??

We have the camel book examples (of course) and Forms 1.0 from Dale Worley
at MIT (but with no examples of how to use Forms we are not able to try it).

Just TRYING NOT TO RE-INVENT THE WHEEL!!

Thanks to all in advance.......

Sandy Bendremer
sandyb@world.std.com
Newsgroups: comp.lang.perl
From: moses@seasnake.micro.umn.edu (Matthew E. Moses)
Subject: Clearing a list
Organization: University of Minnesota, Computer Science
Date: Tue, 1 Sep 1992 02:02:52 GMT

Can anyone forward some hints on clearing a list?  I was modifying one of the 
examples to load and sort a file.  I wrote it as a subprocess and when it gets
called the second time it tacks new items onto the list instead of replacing 
old ones.  Here is a sample piece:


        while(<MAILLOG>)
        {
                select(MAILLOG);
                $username = $_;
                $name = $username;
                $name_list{$name} .= $username;
        }
        close(MAILLOG);


Any tips are appreciated.

*******************************************************************************
* Matthew E. Moses *            __O		 * "How many times do you     *
*  U of Minnesota  *          _ \<,_    	 * hear it? It goes on all    *
* 		   *         (_)/ (_)		 * all day long everyone      *
*  CIS Consultant  * moses@mermaid.micro.umn.edu * knows everthing and no     *
*  ACM Sys Admin   * moses@donald.cs.umn.edu	 * one's ever wrong"	      *
*  Air Force ROTC  * mmoses@epx.cis.umn.edu      * -Show Don't Tell- by RUSH  *
*******************************************************************************

  
Newsgroups: comp.lang.perl
From: dhesi@cirrus.com (Rahul Dhesi)
Subject: Re: randomize.c
Organization: Cirrus Logic Inc.
Date: Mon, 31 Aug 1992 18:39:03 GMT

In <AAS.92Aug31133620@rosmer.nr.no> aas@rosmer.nr.no (Gisle Aas) writes:

>Why not:    perl -e '@l=<>;print splice(@l,rand($#l),1) while @l'

I considered using splice and decided not to take the risk of a
possibly inefficient implementation.  Later I was told that the perl
book already has such a program.

Just how efficient is splice?  I guess it depends on whether arrays in
perl are internally implemented as linked lists.
-- 
Rahul Dhesi <dhesi@cirrus.com>
also: dhesi@rahul.net
From: joel@abigale.UUCP (Joel Rosi-Schwartz)
Newsgroups: comp.lang.perl
Subject: Re: locsym - First major upgrade ;-)
Date: 30 Aug 92 03:48:30 GMT
Organization: Techne Research, Finchampstead, Berkshire (UK)

In article <1349@minya.UUCP> jc@minya.UUCP (John Chambers) writes:
>Marvelous little program! Much better than the  clumsy  sh  tool  that
>I've been using.  I'll keep my old one around for use on systems where
>I can't sneak perl in, but locsym is definitely  better,  even  if  it
>does get its speed by using a chunk of disk.

My ego need that today, thanks ;-)

>
>There was, however, one very curious "bug" in both of the versions, as
>they reached here.  They contained the line:
>
>X		if (/^.*\s+[ATDS]\s+([^_.].*)/o) { $symbol = $1 };
>
>The perl here rejected this because the sequence of tokens  "$1 }"  is
>not  legal.   I  changed the last two chars to ";}" and it worked just
>fine.  It was a bit of a surprise that version 2 had the same problem.
>

This is Okay in 4 PL35 and I think also PL19.  I will include the ";"
in any future release to save the few unfortunates un-needed pain.

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    ||
     ==================================================================
Newsgroups: comp.lang.perl
From: Tom Christiansen <tchrist@convex.COM>
Subject: Re: memory problem with test program
Originator: tchrist@pixel.convex.com
Date: Fri, 28 Aug 1992 14:42:43 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 wierda@ltb.ltb.bso.nl (Gerben Wierda):
:We have several perl programs that use a reasonable lot of data in (assoc)
:arrays. However, freeing those arrays does not make the memory use smaller. Is
:this perl? BSD?

Few if any implementations of UNIX support returning memory to the 
operating system, and even if they did, you'd have coalescing and 
garbage collection issues that would make it hard to give piece from
the malloc pool back to the OS.

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

In the common people there is no wisdom, no penetration, no power of judgment.
	--Marcus Cicero
Newsgroups: comp.lang.perl
From: Mike Morse <mmorse@z.nsf.gov>
Subject: Camel Book for 5.xxx hardback?
Reply-To: mmorse@z.nsf.gov
Organization: The Internet
Date: Tue, 1 Sep 1992 01:32:09 GMT

| If there's going to be a new Camel Book for the new Perl, will it ever
| be available as a hardback?  Of all the books on my shelf the Camel
| Book is the most heavily used (with the possible exception of
| Peopleware which is rarely on the shelf :-) and although it's only 18
| months old it's showing quite a few signs of wear and tear.  How many
| people out there would be interested in shelling out extra money for a
| more durable book?
 
| Just wondering

Do you have a copy from the first printing?  There was a problem with
pages falling out.  I wrote to the publisher and they sent me a new
copy, which seems much more durable.  (I don't think they'll kill me
for posting this--they seem to be genuinely concerned that buyers are
happy with their books.)  I agree with Randall (or is it Randal?) that
soft cover is plenty good for *any* computer book--systems don't stay
around long enough to wear out a hard back.

- --Mike


Newsgroups: comp.lang.perl
From: etxmesa@eos.ericsson.se (Michael Salmon)
Subject: Re: how to 'write' cr-nl
Reply-To: etxmesa@eos.ericsson.se (Michael Salmon)
Organization: Ericsson Telecom AB
Date: Wed, 2 Sep 1992 06:47:19 GMT

In article <400@carssdf.UUCP>, 
watson@carssdf.UUCP (- Self Empl. Sys.Integrator) writes:
[...]
|> entering spaces after the ^M which are not visible by the vi editor,
|> creating leading white space on the next line.

vi can always show you what you have by setting list i.e. :set list
as can cat -e, both are extremely usefull.

-- 

Michael Salmon

#include	<standard.disclaimer>
#include	<witty.saying>
#include	<fancy.pseudo.graphics>

Ericsson Telecom AB
Stockholm
From: jim@spitws117.sbil.co.uk (James Gillespie)
Newsgroups: comp.lang.perl
Subject: Re: Bad label: _EVAL_
Date: 3 Sep 92 12:56:34 GMT
Reply-To: jim@spitws117.sbil.co.uk
Organization: Salomon Brothers International Limited

In article 13684@sbil.co.uk, I wrote:
>The subject just about says it all.  I have written a perl script which
>appears to run okay until it dies with the following message:
>
>	"Bad label: _EVAL_ at <filename> line 367"
>
>line 367 is:
>
>    open (OUTPUT, "> $oldfile") || die "Couldn't open '$oldfile' for writing\n";
>
>For all the difference it makes, $oldfile is defined and has a sensible value.
>I am using perl version 3.0.1.9, patch level 41.
>
>This error has me completely stumped.  Any help will be greatly appreciated.
>Thanks,
>

Oops.  There go another few hundreds or even thousands of dollars.
After a little more experimentation I have discovered the error.  The
script was written to be run by root and $oldfile is a file which is
writable only by root (but readable by everyone).  When I tested the
script as me with a file writable by me, and when I tested it as root
with the original file, it worked fine.  Which leaves me with another
question: why the cryptic bad label error instead of dying with the
given error message?  What did I do wrong?

Thanks again,

Jim Gillespie ----------------------------------------------------
jim@sbil.co.uk              Salomon Brothers International Limited
+44 71 721 2672             ---------------------------------------------------
           "Three strikes and you're history, kiddo!" - Calvin's mom
From: cracraft@wheat-chex.ai.mit.edu (Stuart Cracraft)
Newsgroups: comp.lang.perl
Subject: clip news from news-server
Date: 23 Aug 92 16:40:04 GMT
Organization: MIT Artificial Intelligence Lab


Does anyone have a news clipper that uses a network news-server
as its source for the news?
From: folta@cs.umd.edu (Wayne Folta)
Newsgroups: comp.lang.perl
Subject: String matching with matching delimiters
Date: 31 Aug 92 21:30:16 GMT
Distribution: usa
Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742

I have been doing a lot of work lately manipulating TeX files with perl. Is
there an easy way to give a pattern like:

   /\\hbox{ ... }/

Where the "..." includes everything up to the *matching* brace. This may
include closing braces, so "{[^}]+}" does not work. Presently, I loop through
the string counting opens and closes by hand... I don't think rexegp's are
powerful enough to do it alone, but in perl...

(Also, could rindex be enhanced to be able to match the right-most ocurrence
*before* a certain point? I.e. to be symmetrical with index.)
-- 


Wayne Folta          (folta@cs.umd.edu  128.8.128.8)
From: haynes@cats.ucsc.edu (Jim Haynes)
Newsgroups: comp.lang.perl
Subject: Novice questions
Date: 26 Aug 92 23:05:59 GMT
Organization: University of California; Santa Cruz
NNTP-Posting-Host: hobbes.ucsc.edu


1.  what's the current version?  Using archie I find 4.019 and 4.035
both - is one of these considered the current production version?

2.  where to send bug reports?

Please reply via email.
-- 
haynes@cats.ucsc.edu
haynes@cats.bitnet

"Any clod can have the facts, but having opinions is an Art."
        Charles McCabe, San Francisco Chronicle
Newsgroups: comp.lang.perl
From: dyker@locutus.colorado.edu (Barbara Dyker)
Subject: perl socket filehandles
Organization: University of Colorado, Boulder
Date: Mon, 31 Aug 1992 18:15:15 GMT

I'm trying to write a program that will get started from
inetd.  All I want to do is a getpeername on file descriptor
zero.  How do I assign in perl a particular value to a socket
filehandle so I can do things like getpeername?  I tried
doing simply   
	$mysockaddr = getpeername(0);
which gives me zip.

Sockets are not really my thing so I could be missing something
fundamentally trivial.  It seems that if I wanted to do a
getsockname I would have the same problem.  In this
particular case I don't care much about my end.  Anyone
have such a program I could use as an example?  

Barbara J. Dyker                       Department of Computer Science
Computer Systems Manager               Campus Box 430B, ECEE00-69
barb@cs.colorado.edu                   University of Colorado
(303) 492-2545                         Boulder, CO  80309-0430
From: lwall@netlabs.com (Larry Wall)
Newsgroups: comp.lang.perl
Subject: Re: quoteSplit - Split string into array with embedded quotes
Date: 4 Sep 92 17:09:54 GMT
Article-I.D.: netlabs.1992Sep4.170954.2559
Organization: NetLabs, Inc.

In article <1992Sep4.085440.9025@uvaarpa.Virginia.EDU> dov@menora.weizmann.ac.il writes:
: There is a nice use of m//g in the
: script, and a blasting one-liner, which to the uninitiated certainly
: would look like line-noise.
: 
: #    @list= /"[^"]*"|'[^']*'|[^\s,]+/g;
: #    grep(s/^(["'])(.*)\1$/$2/ + tr/\1\2/"'/, @list);
: #    @list;
: 
:     # This one liner is equivalent to the the three lines above
:     grep(1+s/^(["'])(.*)\1$/$2/+tr/\01\02/"'/,/"[^"]*"|'[^']*'|[^\s,]+/g);

Much as I enjoy a good one-liner,

    grep(
	1 + s/^(["'])(.*)\1$/$2/ + tr/\01\02/"'/,
	/"[^"]*"|'[^']*'|[^\s,]+/g
    );

is much more readable and does the same thing.  If you want to get fancy
and reduce the slash count, you can say (in 4.035):

    grep(
	1 + s<^(["'])(.*)\1$><$2> + tr[\01\02]["'],
	/"[^"]*"|'[^']*'|[^\s,]+/g
    );

It might or might not be a hair faster to say

    grep(
	(
	    s<^(["'])(.*)\1$><$2>,
	    tr[\01\02\03-\377]["'\03-\377]
	),
	/"[^"]*"|'[^']*'|[^\s,]+/g
    );

Interesting though that there's this deep etymological relationship
between various forms of implicit looping and the letter g...

Larry
Newsgroups: comp.lang.perl
From: ejk@ux2.cso.uiuc.edu (Ed Kubaitis - CCSO)
Subject: Re: fast way to get number of elements in an assoc array?
Organization: University of Illinois - Urbana
Date: Thu, 27 Aug 1992 16:41:42 GMT
Keywords: associative array number count $#array $#

jacobsd@prism.cs.orst.edu (Dana Jacobsen) writes:
  |
  |  Is there a function akin to $#array that works on associative arrays? I
  |have an associative array with over 30,000 keys, and this is what I'm 
  |currently doing:
  |
  |    @dummykey = keys(%records);
  |    print $#dummykey+1, " records loaded.\n";
  |    undef (@dummykey);
  |
  |  The problem with this is that the key list takes up a significant chunk of
  |memory, as well as being very slow.  The alternative way of handling this is
  |to keep a seperate variable that contains the number of elements in the 
  |array...

From perl 4.0 patch #20: 

  |Subject: scalar keys %array now counts keys for you

So 'scalar(keys(%records))' or '$nkeys = keys(%records);' should work on 
perl beyond 4.019. Don't know how fast it is on large arrays, though.

----------------------------------
Ed Kubaitis (ejk@ux2.cso.uiuc.edu)
Computing & Communications Services Office - University of Illinois, Urbana
From: vax@ccwf.cc.utexas.edu (Vax)
Newsgroups: comp.lang.perl
Subject: Wanted: chat2.pl library or synonomous stuff
Date: 28 Aug 92 23:17:42 GMT
Organization: The University of Texas at Austin, Austin TX

I am looking for an expect/receive type library for a modem control
perl script.  I was told chat2.pl does this.  Where can I find it
(my distribution didn't come with it I am fairly sure), or could somebody
mail me it?  I have ftp access.  Sorry if this post is in the wrong group.
Should I have posted in a sources.wanted type group?  I dunno.
	In any case, lemme legitimatize this by asking if there is a better
perl library for such things (i.e. looking for prompts with no terminating
newline, and with different last characters for the prompt (so no $/ kludges
or whatever)).
	Thank you greatly for your cooperation.
-- 
EOM
Protect our endangered bandwidth - reply by email.
VAX#N8 vax@ccwf.utexas.edu
Newsgroups: comp.lang.perl
From: ggr@koonda.acci.com.au (Greg Rose)
Subject: Re: perl socket filehandles
Organization: Australian Computing and Communications Institute
Date: Mon, 31 Aug 1992 22:41:14 GMT

In article <1992Aug31.181515.4294@colorado.edu> dyker@locutus.colorado.edu (Barbara Dyker) writes:
>I'm trying to write a program that will get started from
>inetd.  All I want to do is a getpeername on file descriptor
>zero.  How do I assign in perl a particular value to a socket
>filehandle so I can do things like getpeername?  I tried
>doing simply   
>	$mysockaddr = getpeername(0);
>which gives me zip.
>
>Sockets are not really my thing so I could be missing something
>fundamentally trivial.  It seems that if I wanted to do a
>getsockname I would have the same problem.  In this
>particular case I don't care much about my end.  Anyone
>have such a program I could use as an example?  

I tried to reply by e-mail but something went wrong, so anyway...

The socket handling stuff from perl has been rewritten to use perl
filehandles instead of file descriptors -- you are NOT directly
calling the C library. So what you want is

	$mysockaddr = getpeername(STDIN);

and it will work as expected.

--
Greg Rose                 Australian Computing and Communications Institute
ggr@acci.com.au                                              +61 3 282 2532
Newsgroups: comp.lang.perl
From: stantz@sgi.com (Mark Stantz)
Subject: Re: 4.035 bug or feature...why does this run?
Organization: Silicon Graphics, Inc.
Date: Fri, 28 Aug 1992 21:30:55 GMT

In article <1992Aug28.185620.9841@netlabs.com> lwall@netlabs.com (Larry Wall) writes:
> Yes, but note that it's still recommended that you use semicolon in
> general.  You *have* to use it if you want to be backward compatible.
> You *ought* to use it for readability and ease of maintenence unless
> you're writing very short block that fits on one line along with its
> braces:
>
>    sort { $a <=> $b } @list;
>    sub println { print @_,"\n" }
>    do { &one } until $done;

	Er... what was wrong with:

		sort { $a <=> $b; } @list;
		sub println { print @_,"\n"; } 
		do { &one; } until $done;

	Or is this one of those religious arguments again?

	Such arguments notwithstanding, my concern is that now and then I 
just plain forget to put the semi-colon at the end of a line.  Call it a typo
or a mental lapse.  Usually perl complains and I fix it instantly...it's not
really a problem, and the same thing happens to me in C all the time.  The 
real trouble comes when you post code to the net not realizing that you 
forgot one of those semi-colons, and it doesn't run for half the people that 
try to use it, even though it works fine for you.  

	At the least, 'perl -w' should warn you about the backward 
incompatability problem.

	-Mark
Newsgroups: comp.lang.perl
From: pwh@bradley.bradley.edu (Pete Hartman)
Subject: Re: Camel Book for 5.xxx hardback?
Organization: Bradley University
Distribution: usa
Date: Fri, 4 Sep 92 14:02:37 GMT

In <1992Sep4.065932.1667@newross.Princeton.EDU> dem@cs.princeton.edu (Doron Meyer) writes:
>I would have to wholeheartedly disagree.  I bought copy of K&R 2 a few
>years ago in hardback around the same time my friend bought the
>softcover version.  Mine is still in good condition, while his is
>falling apart.  If a Fortran has lasted until now, I think my book
>will fall apart before ANSI C does.

I think this says more about how your friend uses books.  I have a
hoary copy of K&R 1 in softcover that is a number of years old, and
while it is obviously well-used, it is nowhere near falling apart.
-- 
Pete Hartman		       Bradley University	pwh@bradley.bradley.edu
        People say that I'm out of touch with reality.  That I'm insane.
    Sometimes I forget things.  Who I am.  Where I am.  Unimportant things.
                       But I'm not insane.  I am a tick.
Newsgroups: comp.lang.perl