HDTenEightyP/NetNews huggingface dataset:
From: pem@yarra-glen.aaii.oz.au (Paul E. Maisano)
Subject: LVALUE =~ EXPR ?
Organization: Australian Artificial Intelligence Institute
Date: Sat, 29 Aug 1992 05:32:35 GMT

[Apologies if anyone receives this message twice...]

I was rather expecting (hoping for?) this to work:

($x = 'ab') =~ (s/a/A/, s/b/B/);
print "$x\n";

I was expecting the output to be "AB".
I thought the =~ would modify the context for the whole RHS.
Well, to be honest, I was expecting either that or a syntax error.

There was no syntax error but it did not do what I expected either.
I read the manual to see what it said but I found it a little hard to
work out exactly what it meant.

[Here is what it says to save you the trouble of looking it up.

     =~      Certain operations search or modify the string  "$_"
             by default.  This operator makes that kind of opera-
             tion work on some other string.  The right  argument
             is  a  search pattern, substitution, or translation.
             The  left  argument  is  what  is  supposed  to   be
             searched,  substituted, or translated instead of the
             default "$_".  The return value indicates  the  suc-
             cess of the operation.  (If the right argument is an
             expression other than a  search  pattern,  substitu-
             tion,  or translation, it is interpreted as a search
             pattern at run time.  This is less efficient than an
             explicit  search, since the pattern must be compiled
             every time the expression is  evaluated.)  The  pre-
             cedence  of  this operator is lower than unary minus
             and autoincrement/decrement, but higher than  every-
             thing else.]

Does anyone think the above should work ?

Or are we stuck with:

$x = 'ab';
$x =~ s/a/A/;
$x =~ s/b/B/;

Or more likely,

$_ = 'ab', s/a/A/, s/b/B/;

I really like the way perl lets you change the context for substitions
(and matches and translates) using =~ (I find it quite intuitive) but
I was hoping it was a little more general.

-paul

---
Paul Maisano                  pem@aaii.oz.au
Australian Artificial Intelligence Institute
Newsgroups: comp.lang.perl
Subject: more questions
From: steiner@jupiter.cse.utoledo.edu (jason "Think!" steiner)
Date: 26 Aug 92 03:30:44 EST

here's something i've been wondering about:

what's the best way to pipe output through a pager? (in this case more)
i've tried just opening "|more", but that hangs on close, apparently
because more is waiting for its parent to finish, and perl is waiting
for more to exit. this also has the disadvantage that quitting more
half way through the output also quits perl.

i've got a feeling this is very simple, but don't know what it is...

--
`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`
`, "I'm the keeper of the cheese, and you're the lemon merchant!" - Ren Hoek ,`
`,`,`,`,`,`,`,`,`,`,`,` steiner@jupiter.cse.utoledo.edu `,`,`,`,`,`,`,`,`,`,`,`
From: meissner@osf.org (Michael Meissner)
Newsgroups: comp.lang.perl
Subject: Re: fast way to get number of elements in an assoc array?
Date: 27 Aug 92 14:37:24 GMT
Organization: Open Software Foundation

In article <1992Aug27.032106.20515@CS.ORST.EDU> jacobsd@prism.cs.orst.edu (Dana Jacobsen) writes:

| 
|   Is there a function akin to $#array that works on associative arrays?

	int (scalar (%array))
--
Michael Meissner	email: meissner@osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

You are in a twisty little passage of standards, all conflicting.
Newsgroups: comp.lang.perl
From: Tom Christiansen <tchrist@convex.COM>
Subject: Re: Using $*, but pattern doesn't match
Originator: tchrist@pixel.convex.com
Date: Tue, 25 Aug 1992 21:45:17 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 ram@eiffel.com (Raphael Manfredi):
:You have to use [.\n] if you want to match anything.

Sorry, [] is a nonmagical zone, so your dot is a literal.
Often we use [^\0] to mean (just about) anything.

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

    Though I'll admit readability suffers slightly... 
                    --Larry Wall in <2969@jato.Jpl.Nasa.Gov>
Newsgroups: comp.lang.perl
From: phillips@cs.ubc.ca (George Phillips)
Subject: Re: die hook
Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
Date: Thu, 27 Aug 92 05:25:30 GMT

In article <1992Aug15.030457.21382@netlabs.com> lwall@netlabs.com (Larry Wall) writes:
>The code I'm developing for Perl 5 already has two magical subroutines
>in it called BEGIN and END.  They're so magical that you don't even have
>to put "sub" in front of them.  BEGIN is automatically called before
>the program starts, and END is automatically called just before the
>program exits, no matter how it exits.

Do you get a magical BEGIN and END for each package or just one set for
the entire program?  Seems like it would be a great way for required
subroutine modules to install cleanup routines without extra bookkeeping
on the part of the main program.  The BEGIN subroutine may be a problem
since the earliest it could run would be at require time, but then
again required files already have BEGIN.

I guess you could make non-lazy programmers write out their ENDing
sequence explicitly:

	END {
		&foo'END;
		&bar'END;
		print "Bye!\n";
	}

But that means that some day you'll forget to add an END call when
you do a require.  I think it would be better to call each package's
END in reverse order of initial definition of each package (which
guarantees main'END would be last, right?).  You might be upset
that the main program cannot decide for itself if a module should
be shut down, but it's only fair to assume that if a module needs
to prepare for death it has good reasons for doing so.
Newsgroups: comp.lang.perl
From: stripes@pix.com (Josh Osborne)
Subject: Re: Camel Book for 5.xxx hardback?
Organization: Pix Technologies -- The company with no adult supervision
Date: Tue, 1 Sep 1992 12:46:35 GMT

In article <rick.51.715294926@sjsumcs.sjsu.edu> rick@sjsumcs.sjsu.edu (Richard M. Warner) writes:
>Interesting idea.  If the camel book is too thick for this binding,
>what about some of the X books?  The PEX book came out about 4-5
>months ago and is 2-1/2 times as thick as the 'camel'.  Maybe the
>market researchers should contact PEX book buyers and see how the
>binding is holding up

The PEX book *is* hardback.
-- 
           stripes@pix.com              "Security for Unix is like
      Josh_Osborne@Real_World,The          Multitasking for MS-DOS"
      "The dyslexic porgramer"                  - Kevin Lockwood
We all agree on the necessity of compromise.  We just can't agree on
when it's necessary to compromise.       - Larry Wall
From: tony@hacgate.SCG.HAC.COM (Tony Reeves)
Newsgroups: comp.lang.perl
Subject: how to get passwd
Date: 31 Aug 92 23:39:53 GMT
Reply-To: tony@hacgate.UUCP (Tony Reeves)
Distribution: usa
Organization: Hughes Aircraft Co., El Segundo, CA

I'm new to perl, so I'm sorry if this is a dumb question...

I want to read the last line of /etc/passwd and grep out the uid number. 
I can't seem to do this. How can I do this easy? I tryed open, seek and split.
But it does not seem to work the way I read it in the man page. Can a perl
expert help me?

-- 
Why did the Roman Empire Collapse? What is latin for Office Automation?
---- The opitions expressed here are mine and have nothing to do with Hughes
Aircraft Co. -- So there! tony@hacgate.hac.com
From: lwall@netlabs.com (Larry Wall)
Newsgroups: comp.lang.perl
Subject: Re: How fast is... (was Re: randomize.c)
Date: 3 Sep 92 19:05:04 GMT
Article-I.D.: netlabs.1992Sep3.190504.12797
Organization: NetLabs, Inc.

In article <1992Sep2.135055.4659@Warren.MENTORG.COM> tal@Warren.MENTORG.COM (Tom Limoncelli) writes:
: In <1992Sep1.210332.26149@netlabs.com> lwall@netlabs.com (Larry Wall) writes:
: 
: >      ......                      Subscripting, however, happens
: >constantly, so we optimize for that.
: 
: Are associative arrays optimized?  For example, many times I do:
: 
: if ( $foo{$thing} ne $frob ) {
: 	$foo{$thing} += $fratz;
: }
: 
: Is there a one-entry cache or does it traverse the hash tables twice?

Well, traverse is perhaps a misleading word, since it usually lands
right on the entry in question.  But it does calculate the hash value
twice.  It doesn't know offhand that the value of $thing hasn't changed
in the meanwhile.  It could be made to.  But you lose most of the
advantage if you have to compare the two strings to find out.  The right
way to do that is to associate the hash value with the string, and
invalidate it if the string changes.  I'll need to redo how scalars
are stored for Perl 5 anyway, so something like that might sneak in.
Certainly an evaled string ought to cache its parse tree, and this is
quite similar.

Larry
Newsgroups: comp.lang.perl
From: rahardj@ccu.umanitoba.ca (Budi Rahardjo)
Subject: Re: Looking for MS-DOS port of perl?
Organization: University of Manitoba, Winnipeg, Canada
Date: Wed, 26 Aug 1992 18:14:25 GMT

albert@INSL.McGill.CA (Albert Pang) writes:
...
>Is anyone who has perl executable and are willing to share it with the
>rest of the world.  It will be much appreciated.

Try anonymous fto to ftp.ee.umanitoba.ca:/pub/msdos/perl

-- budi
-- 
Budi Rahardjo <rahardj@ccu.umanitoba.ca>
Unix Support - Computer Services - University of Manitoba
Newsgroups: comp.lang.perl
From: glenn@clsi.COM (Glenn Boysko)
Subject: Ordering indices based on their values
Organization: CAD Language Systems Inc.
Distribution: comp.lang.perl
Date: 26 Aug 92 12:24:20


Hello Perl Hackers,

I was wondering if anyone knew of an efficient, simple way to produce an
ordered array of indices whose order was based on their values.  Consider the
following array:

	Index | Value
	------+------
	  0   |  7
	  1   |  2
	  2   |  4
	  3   | -1
	  4   |  5

I would like a new array whose values are indices of the input array.  The
values of the new array are ordered such that their values in the original
array are ordered in descending order.  The resulting array for our example
is:

	Index | Value
	------+------
	  0   |  0
	  1   |  4
	  2   |  2
	  3   |  1
	  4   |  3

Note that an appropriate solution would be to use an associative array to
store (value, index) entries and then sort the keys.  However, this will not
work if the values of the original array are not distinct.

Once this array has been generated, I can process each entry in the orignal
array according to the descending order of the values.

Any Ideas?
Glenn


	
--
......................... *                           *   
..=====.==....=====..===. | Glenn Boysko              | "An eye for an eye,
.======.==...===.....===. | CAD Language Systems, Inc |  a tooth for a tooth,
.==.....==....===....===. |                           |  vote for me and
.======.====....===..===. | glenn@clsi.COM  OR        |  I'll set you free."
..=====.====.=====...===. | uunet!clsi!glenn          |        -- Daniel Ash
......................... *                           *
Newsgroups: comp.lang.perl
From: hansk@aie.nl (Hans Kinwel)
Subject: Very tiny bug in printf?  (perl 4.034)
Organization: AI Engineering BV, Amsterdam, The Netherlands
Date: Thu, 3 Sep 1992 02:05:23 GMT


I expected the following three lines to print out 08 two times.

$val="8";
printf ("%02s\n", $val);
printf ("%02d\n", $val);

It does, under perl 3.044. My perl 4.034 does not, however.
There the first zero gets replaced by a space. This is under ISC 3.0.
Not a big deal, of course. But it bit me.
Is it me? Can't I read manpages? Is it old news? 

Oh well, here it is. FYI.

And now I have the mike: thank you Mr Wall, Christiansen and Schwartz 
(do I dare say Larry, Tom and Randal? Nah... :) for the tremendous
support you give in this group.


-- 
| "The meek shall inherit the Earth --            |       hansk@aie.nl        |
|  The rest of us will go to the stars." -- R.H.  |  (old Henry Spencer sig)  |
From: daleske@cbnews.cb.att.com (John D. Daleske)
Newsgroups: comp.lang.perl
Subject: Availability of "undump"?
Summary: Where can I find "undump"?  Better way to use compiled perl?
Keywords: undump compilation compiled perl
Date: 3 Sep 92 18:36:24 GMT
Distribution: na
Organization: AT&T

The Camel Book refers to "undump" as not being generally available or even
sometimes not possible for a particular architecture.

Is the source for "undump" available and if so, where could I find it?  I'd
like to port it to four different architectures in my current environment.
(Amdahl UTS, Sun 4, Stratus FTX 1, Stratus FTX 2).

Thanks much!
John
From: chrise@hpnmdla.sr.hp.com (Chris Eich)
Date: Fri, 28 Aug 1992 21:03:03 GMT
Subject: Re: oddity in syslog.pl
Organization: Hewlett-Packard, Santa Rosa, CA
Newsgroups: comp.lang.perl

It's what you get when you run "h2ph syslog.h".

Chris
Newsgroups: comp.lang.perl
From: jhd@irfu.se (Jan D.)
Subject: Re: usersub: HOW TO
Date: Mon, 31 Aug 1992 07:20:37 GMT
Distribution: comp.lang.perl
Organization: Swedish Institute of Space Physics, Uppsala, Sweden

In article <ROBT.92Aug29232737@idt101.is.morgan.com> robt@is.morgan.com (Rob Torop) writes:

	[ usub examples deleted ]


I have some suggestions for the makefile.

Some makes can't make a .o from a .mus even if they know how to make
a .c from a .mus. I suggest you change

	.mus.c:
		mus $*.mus > $*.c

to
	.mus.o:
		mus $*.mus > $*.c
		$(CC) -c $(CFLAGS) $*.c

if you have such a make (GNU make isn't one of them).

Also the libs perl wants are missing. You can find them like this:

LIBS = `/bin/sh -c '. $(PERLSRC)/config.sh ; echo $$libs'`

	Jan D.

Newsgroups: comp.lang.perl
From: ohrd!rberesh@cs.toronto.edu (R. Beresh)
Subject: Re: Looking for MS-DOS port of perl?
Reply-To: torsqnt!ohrd!rberesh@cs.toronto.edu (R. Beresh)
Organization: Ontario Hydro Research Division
Date: Mon, 31 Aug 92 18:24:56 GMT

In article <BttnIz.5CB@jrd.dec.com> doi@jrd.dec.com (Hitoshi Doi) writes:
& 
& I'm working on building perl 4.035 with a more recent version of DJGPP.
& I hope some of these problems get fixed.
& --

Could you possibly build-in gdbm support?  I have not been able to 
find a DOS port of 4.035 with this feature added.

Thanks


-- 
Bob Beresh                     phone:  (416) 231-4111 ext 6505
Ontario Hydro                  FAX:    (416) 231-6384
800 Kipling Ave (MS KR132)     (follow-up please use address below NOT header)
Toronto, Ontario, M8Z 5S4      net: torsqnt!ohrd!rberesh@cs.toronto.edu
Newsgroups: comp.lang.perl
From: witr@rwwa.COM (Robert Withrow)
Subject: Re: Camel Book for 5.xxx hardback?
Reply-To: witr@rwwa.com
Organization: R.W. Withrow Associates
Distribution: usa
Date: Tue, 1 Sep 1992 19:06:49 GMT

In article <sherman.715286966@foster>, sherman@unx.sas.com (Chris Sherman) writes:
| Actually, the Perl book on CD-ROM would be really handy!!!  I would be willing
| to pay bucks for all the 'animal' O'Reilly books on a CD-ROM.

Is there some sort of standardized freely available document browser that
is up to the task?  Something like DEC's Bookreader?

-- 
---
 Robert Withrow, R.W. Withrow Associates, Swampscott MA 01907 USA
 Tel: +1 617 598 4480, Fax: +1 617 598 4430, Net: witr@rwwa.COM
Xref: sparky comp.lang.perl:5605 alt.security:4222
From: hom00@ccc.amdahl.com (Harold O Morris)
Newsgroups: comp.lang.perl,alt.security
Subject: Malformed cmd Links
Date: 30 Aug 92 19:50:13 GMT
Reply-To: hom00@JUTS.uts.amdahl.com (Harold O Morris)
Organization: Amdahl Corporation, Sunnyvale CA

Another user wrote in about this problem, in a different context.  I have
a sort of interactive Perl environment, that lets me iteratively hack on
a perl subroutine til I get it right.  The trouble is, since 4.035, it
seems to give this error message ("Malformed cmd links"), whenever I have
it "do" a module containing definition of a previously defined subroutine.

Previously, it seemed to redefine routines just fine, and I don't know if
there were any problems, such as "leaking" the data storage representing
the old version of the subroutine.  Has Perl indeed adopted a policy of
not liking redefinitions of subroutines?  (and if so, what a cryptic way
to tell me - the error message sounds not particularly intended for users'
tender ears/eyes).
From: ericw@hobbes.amd.com (Eric Wedaa)
Newsgroups: comp.lang.perl
Subject: Re: help with if ( ! $a =~ /##/ ) PLEASE!!!
Date: 29 Aug 92 00:36:53 GMT
Distribution: usa
Organization: Advanced Micro Devices, Inc.

Once again proving, "There's More Than One Way To Do It."

>Eric> == Eric Wedaa <ericw@bach.amd.com> 

> Eric> I am having a h!@# of a time getting this code fragment to 
> Eric> work:

> Eric> if ( ! $a =~ /#/ ){
> Eric> 	some_random_bit_of_perl;
> Eric> }


>if ($a !~ /#/) {
>        some_random_bit_of_perl;
>}

and 

>if (!($a =~ /#/ )){
>        some_random_bit_of_perl;
>}

Thanks!

--
Eric Wedaa  -  eric.wedaa@amd.com | Two more kinds of lies...
{ames apple uunet}!amd!ericw      |     Release Dates, and Benchmarks
Advanced Micro Devices, M/S 167 PO Box 3453 Sunnyvale, CA 94088-3453
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Newsgroups: comp.lang.perl
From: asherman@laser.fmrco.com (Aaron Sherman)
Subject: Re: got a symlink checker/chaser for crontab?
Organization: I-Kinetics, 19 Bishop-Allen Dr., Cambridge, MA
Date: Thu, 27 Aug 1992 22:03:23 GMT


I just posted (mere days ago) an article titled:

	"Re: Filename expansion ("~user")"
		(ID: <ASHERMAN.92Aug22193046@laser.fmrco.com>)

This contained a library routine for perl that did lots of file-name
resolution like that.

But, for your purposes, this will work:

	#!/usr/local/bin/perl -- # Or wherever...
	# WARNING: UNTESTED!!!

	open(P,'find / -type -l -print 2> /dev/null |') ||
		die("Cannot fork: $!\n");

	while(<P>)
	{
		print "No such file: ", readlink($_), " pointed to by: ",
			$_, "\n" if (! -e $_);
	}
	close(P); # Kill damuda

	exit(0);
--
--------
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: lwall@netlabs.com (Larry Wall)
Newsgroups: comp.lang.perl
Subject: Re: Why is this foreach loop exiting early?
Date: 27 Aug 92 06:24:34 GMT
Organization: NetLabs, Inc.

In article <123@eiffel.eiffel.com> ram@eiffel.com (Raphael Manfredi) writes:
: Quoting nlane@well.sf.ca.us (Nathan D. Lane) from comp.lang.perl:

You mean, Diana Lane, not Nathan.  Tsk, tsk...   :-)

: >chop(@farms = `cat $file`);
: 
: That is your problem. That is a "shell" behaviour. What you want is more:

Nope, guess again.  chop(@foo = `cat $file`) does just what the lady expects.

: If the file is really big, it might be better (for memory usage) to write:
: 
: open(FARMS, $file) || die "Can't open $file: $!\n";
: @farms = <FARMS>;	# Because $/ is "\n" and we are in array context
: close FARMS;

If you're simply going to iterate over it you might as well use:

    while (<FARMS>) {
	...
    }

: >The program doesn't reach the second record, or at least doesn't process it.
: >Needless to say, it doesn't find the INDEX line either (which is why I
: >haven't gotten that part of the processing to function).  Any help would be
: >appreciated, including suggestions on style.  I do want to learn!
: 
: So no wonder, it did not work, you were trying to process one big line,
: and $* is 0 by default so you did not match anything I guess.

Mmm.  No.

: Oh, BTW, I've just spot what might be a typo... Further down in your script,
: you write:
: 
: 	if ($farm =~ /INDEX/) {
: 		next until /\d+/;
: 		($Seq, $rest) = split(' ', $farm);
: 	}
: 
: Surely you meant 'unless' instead of 'until'.

Yes, surely.

I don't know what the real problem is, but the way to solve it is to
put print statements in to print out the value of things like $abbrev
and $Farm{$seq} at appropriate places.  A nice trick is

    warn $abbrev if $DEBUGGING;

Then it automatically annotates it with the line number for you.
Nothin' says that warn really has to produce a warning...

If one of those variables weren't getting set the second time then the
program might just be appending more newlines to the first output file,
or some such.

You might also try perl -d to step through it.

Larry
From: lwall@netlabs.com (Larry Wall)
Newsgroups: comp.lang.perl
Subject: Re: String matching with matching delimiters
Date: 1 Sep 92 21:26:35 GMT
Distribution: usa
Organization: NetLabs, Inc.

In article <59999@mimsy.umd.edu> folta@cs.umd.edu (Wayne Folta) writes:
: 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...

I've considered adding some kind of automatic tokenizing, but for now
you just have to s/// the front off the string and count brackets.  This
is really way beyond the capabilities of regular expressions.

: (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.)

Already does.  Try supplying a third argument.

Larry
Newsgroups: comp.lang.perl