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

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

1
15-OCT-1992 17:33:08.53
   1 00:00:00.00
16-OCT-1992 17:33:08.53
perl-users-dist-request@fuggles.acc.Virginia.EDU
rafapa@obelix.cica.es

Received: from fuggles.acc.Virginia.EDU by ESEVVX.CICA.ES ; 12-OCT-1992 17:32:46.96
Received: from fuggles.acc.Virginia.EDU by fuggles.acc.Virginia.EDU id aa11332;
          12 Oct 92 12:13 EDT
Received: from uvaarpa.virginia.edu by fuggles.acc.Virginia.EDU id aa11328;
          12 Oct 92 12: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:     Mon, 12 Oct 92 12:12:15 EDT
Subject:  Perl-Users Digest #601

Perl-Users Digest #601, Volume #2                Mon, 12 Oct 92 12:12:15 EDT

Contents:
  Re: Perl on Cray (Bill Jones)
  Re: OOP?  Dynamic Loading of C code and packages for perl (Tom Christiansen)
  Re: writing binary data (beginner's question) (Tom Christiansen)
  Re: Where do I find my packages? (Tom Christiansen)
  Re: how does one tar to stdout? and related? (Kazumasa Utashiro)
  Re: Visual (Randal L. Schwartz)
  Re: associative arrays with variable numbers of fields (Mandeep S Dhami)
  Sorting associative arrays based on the value (Shane Youl)
  Re: Sorting .newsrc (Kazumasa Utashiro)
  setuid scripts (Nick Crossley)
  question about perl patterns (Sanjay Kumar at Cold Spring Harbor Lab)
  Re: Building on SunOS 4.1.2 -- Core dump... (Joel Rosi-Schwartz)
  Re: Malformed cmd links (Bill Mann)
  Re: Malformed cmd links (Tom Christiansen)
  Re: Sorting associative arrays based on the value (Tom Christiansen)
  ARGV parsing (Tobias Weingartner)
  Re: question about perl patterns (Tom Christiansen)

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

From: jones@chpc.utexas.edu (Bill Jones)
Subject: Re: Perl on Cray
Date: Mon, 12 Oct 92 01:09:39 GMT


|Has anyone successfully compiled perl 4.035 on a Cray YMP?
|The config file would seem to indicate that it is possible.
|We have a Cray YMP running Unicos 6.1.  I get lots of
|"not enough stack space" errors when I try to compile it.
|
|Any clues?

The "not enough stack space" error is due to sh running out of
stack space.   You can increase the stack space by adding the 
"-m" parameter in every shell script that use the ". file" sh
command or recompiling sh with a bigger default stack.

I sure wish cray would fix this!

Bill  Jones




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

From: tchrist@convex.COM (Tom Christiansen)
Crossposted-To: comp.lang.tcl
Subject: Re: OOP?  Dynamic Loading of C code and packages for perl
Date: 12 Oct 92 01:38:43 GMT
Reply-To: tchrist@convex.COM (Tom Christiansen)

From the keyboard of thayer@cs.columbia.edu (Charles Thayer):

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

Current thinking holds that ["$a $b"] would be a pointer to 
a list containing one element, the string "$a $b", like

    \( "$a $b" )
or using the function=call syntax

    ref ("$a $b")

Although I get nervous about the function-call syntax.

Let's see now, are you talking about 

    &{$a}($b);

That is, call the function whose name is in $a with the argument $b?
How can you tell the name?

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

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

:in C and take and return a string.  And [["$a $b baz"] `ypmatch foo bar`]
:would do what you'd expect too.

You mean this:

    &{&{$a}($b,baz)}(`ypmatch foo bar`);

:it's syntactic sugar that makes perl
:look more like smalltalk.  

People often want Perl to look more like other languages than Perl. :-)

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

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

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

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

:-Someone's already written a sybased tcl.

And a sybased (etc.) perl.

:-Tcl could implement struct for perl.

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

:-We could get rid of some of the features already in perl.

I don't think you'll make a lot of friends by removing features,
since most have their champions.  Did you have any candidates for 
deletion?

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


		Cloning is the sincerest form of flattery.

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

From: tchrist@convex.COM (Tom Christiansen)
Subject: Re: writing binary data (beginner's question)
Date: 12 Oct 92 01:41:50 GMT
Reply-To: tchrist@convex.COM (Tom Christiansen)

From the keyboard of majidi@rwja.umdnj.edu (Masoud Majidi):
:Dear netters,
:
:I have been trying to store some int as binary data in a file and I thought
:something like the following would work:
:
:syswrite (TO, $value, 4)
:
:where $value is say 5 and 4 is the num of bytes in an integer. But the ascii
:value of data is stored in the file. Could you please somebody tell me what
:am I missing?

    print TO pack("I", $value);

is what you want.  You never get automatic conversion to binary 
data in Perl.  You have to ask for it explicitly.

--tom

-- 
    Tom Christiansen      tchrist@convex.com      convex!tchrist
If you want to see useful Perl examples, we can certainly arrange to have
comp.lang.misc flooded with them, but I don't think that would help the
advance of civilization.  :-) --Larry Wall in <1992Mar5.180926.19041@netlabs.com>

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

From: tchrist@convex.COM (Tom Christiansen)
Subject: Re: Where do I find my packages?
Date: 12 Oct 92 01:51:11 GMT
Reply-To: tchrist@convex.COM (Tom Christiansen)

From the keyboard of sommar@enea.se (Erland Sommarskog):
:Is there some special place somewhere I can find the names of
:all packages in my script?

Run down all the keys in %_main{} and check their values
for magic best derived by checking out the debugger.

:The background problem: I have a general abort routine which I
:call instead of simply saying "die". Today it looks for a cleanup
:routine in the main and the locks packages if they are defined, 
:but it would be much more elegant if I could traverse the array 
:of packages, and call each cleanup routine I find.

Instead of looking through the symbol table, have each return
register an atexit() function to call.

:By the way, it would be a nice extention to the language if
:dies were trappable to faciliate when you need to do some
:cleanup before you exit.

Already happens.  It's called eval.  Do something like this:

        sub atexit { push(@_exit_subs, @_); }

        sub _cleanup { unlink $tmp; }

        &atexit('_cleanup');

        eval <<'End_Of_Eval';  $here = __LINE__;
        # as much code here as you want
        End_Of_Eval

        $oops = $@;  # save error message

        # now call his stuff
        for (@_exit_subs) {  do $_(); }

        $oops && ($oops =~ s/\(eval\) line (\d+)/$0 .
            " line " . ($1+$here)/e, die $oops);


Put the main code between the eval and End_Of_Eval. I'd just make a
function &main and call that myself, like:

    eval '&main()';

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

    "It is easier to port a shell than a shell script."
		--Larry Wall

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

From: utashiro@sran230.sra.co.jp (Kazumasa Utashiro)
Subject: Re: how does one tar to stdout? and related?
Date: Mon, 12 Oct 1992 01:40:02 GMT
Reply-To: utashiro@sra.co.jp

In article <1992Oct8.184423.27220@fnbc.com>
	jja@fnbc.com (Joseph Alotta) writes:
|> i have a problem getting tar to write to stdout.  i can get it to read  
|> from stdin, but not the other way around.  i have these large files on 
|> tape and i want to read and subset them before i write them on disk  
|> because they are really big.  i'd like to do something like:
|> 
|> tar -xvf /dev/rst0  mybigfile | grep "1000" | filter.pl

I made a program called "taro" and that is probably you
want.  You can use it like this:

	taro cat /dev/rst0 yourbigfile | whatever you want
or
	taro s:yourbigfile:/dev/stdout: /dev/rst0 | tar xf - /dev/stdout

You can get taro via anonymous ftp from

	sra.co.jp[133.137.4.3]:pub/lang/perl/sra-scripts

You can also find it in comp.lang.perl or alt.sources archives.

---
K.Utashiro
utashiro@sra.co.jp

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

From: merlyn@ora.com (Randal L. Schwartz)
Subject: Re: Visual
Date: 12 Oct 92 07:35:35 GMT

In article <ASHERMAN.92Oct9144342@piranha.fmrco.com> asherman@fmrco.com (Aaron Sherman) writes:
   Hmm.... For that matter I've never seem Tom and Randal at ALL. I think
   they're just perl scripts, written by his Wallness. ;-)

Well, I haven't seen Tom or Larry in the last 15 minutes.  Maybe they
*have* been replaced.  Horrors.

Then again, I haven't seen myself all day.  Just my hands and feet.
Maybe I'm a robot now.  That'd explain the sudden urge to find a can
of 10W-40.

for("larry","tom","randal"){ print(("Just another ","Perl ","hacker,")[$i++]);}
--
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: dhami@cs.ubc.ca (Mandeep S Dhami)
Subject: Re: associative arrays with variable numbers of fields
Date: 12 Oct 1992 00:48:29 -0700

brennan@alc.com (Tom Brennan) writes:
|
| I have a text file of the following format:
| 
| key_value	attribute1	attribute2
| key_value	attribute1
| key_value	attribute3
| key_value	attribute4	attribute5	attribute6
| 
| I would like to read this file into an associative array, but 
| as you can see, there are variable numbers of attribute fields.
| Would this be adviseable? 
| 
| I would like to do processing to answer questions like how many 
| occurances of attribute3 occur in this file. Also, I would like
| do processing which would find which attributes are associated with
| a given key value.
| 

An easy way is to use 2 associative arrays:
while(<FILE>) {
    split;
    $for_key{shift(@_)}=join("\377",@_); # Overwrites repeated values,
				         # Can use .=("\377".join(...))
    grep($for_attr{$_}++,@_);
}

Then you can answer:
1. What are the keys? as:
    print join(' ',sort(keys(%for_key))),"\n";

2. What are attributes of key $X? as:
    print join(' ',split("\377",$for_key{$X})),"\n";

3. What are all the attributes? as:
    print join(' ',sort(keys(%for_attr))),"\n";

4. How many times does attr. $Y occur? as:
    print "$Y occures - ",$for_attr{$Y}||0,"times\n";

Mandeep.
__________________________________________________________________
"I'm very brave generally," he went on in a low voice:
"only to-day I happen to have a headache."
                                      -- Lewis Carroll
__________________________________________________________________

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

From: sfy@koel.mel.dit.CSIRO.AU (Shane Youl)
Subject: Sorting associative arrays based on the value
Date: Mon, 12 Oct 92 08:29:06 GMT

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.

Thanks...Shane
--
  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: utashiro@sran230.sra.co.jp (Kazumasa Utashiro)
Subject: Re: Sorting .newsrc
Date: Mon, 12 Oct 1992 05:04:30 GMT
Reply-To: utashiro@sra.co.jp

In article <1b327uINNm3i@agate.berkeley.edu>
	dwallach@zonker.cs.berkeley.edu (Dan Wallach) writes:
|> # New feature in 1.4
|> #
|> # cleaned up the eval in sub insert, it's now evaling the loop instead
|> # of being within it.  This optimizes (/pat/) perl patterns; it now runs in
|> # much less time on my sample .news.favorite (with a 2500+ group .newsrc!)
|> #
|> #old: 44.0u 15.9s 1:10.66 84.9% 0+1080k 5+15io 0pf+0w
|> #new: 12.4u  9.7s 0:27.94 79.7% 0+1012k 3+15io 0pf+0w

I compared "fixnewsrc" with my "newsrc" program to sort
1700+ lines .newsrc by exactly same order on 20MHz R3000
machine.

fixnewsrc: 5.080u 0.720s 0:06.70 86.5% 72+298k 12+10io 2pf+0w
newsrc:    1.030u 0.190s 0:01.57 77.7% 74+100k 2+9io 3pf+0w

You can use shell style wildcard to specify the order of
newsgroups.  "newsrc" is available by anonymous ftp from
sra.co.jp[133.137.4.3]:pub/lang/perl/sra-scripts.

--utashiro

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

From: ndjc@leo.irv.icl.com (Nick Crossley)
Subject: setuid scripts
Date: 8 Oct 92 01:36:20 GMT

As I understand it, the security hole in setuid scripts is believed to
be fixed in systems using /dev/fd to pass the file id over to the
interpreter (such as SVR4 and I would guess BSD 4.4).

If this is true, should perl 5 ask about this at config time and allow
setuid scripts on such systems?
-- 

<<< standard disclaimers >>>
Nick Crossley, ICL NA, 9801 Muirlands, Irvine, CA 92718-2521, USA 714-458-7282
uunet!ccicpg!ndjc  /  ndjc@irv.icl.com

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

From: kumar@phage.cshl.org (Sanjay Kumar at Cold Spring Harbor Lab)
Subject: question about perl patterns
Date: Mon, 12 Oct 1992 13:06:55 GMT

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.

Sanjay Kumar
kumar@neb.com
. 


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

From: joel@abigale.UUCP (Joel Rosi-Schwartz)
Subject: Re: Building on SunOS 4.1.2 -- Core dump...
Date: 12 Oct 92 12:01:14 GMT

Hi,

I got a reponse from Dave Greunke, which is attached below.  His
advice solved the problem and I know have working perls on the
Sun with both Suns cc and gcc.  Thanks Dave,  I tried to E-mail
you back both the Inet and UUCP addressed you list, but both
bounced.  If your are interested in why I have saved the baunce
reports, the only problem is how to get them to you without
posting them, to c.l.p  ;-)

Cheers,
Joel

|>|> 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
|
|Cheers,
|Joel

I'm not sure that this is your problem but I had similar problems building
perl 4.35 on a Sparc IPC under 4.1.1 with gcc2.2.2. Try rerunning the
configure script and when it come to the line where it adds extra flags
to pass to gcc it will probably try to include /usr/ucb/include on that
line. DON'T let it do that. I think what happens if you let this get thru is
varargs.h gets included when it shouldn't which causes all the perl routines
that use varargs() to get screwed up. Hope this trick works for you. It made
things run much better on my machine.


	Dave

-- 
===============================================================================
Dave Greunke                        | Internet:
Consultant                          | maplgrv!vid%astroatc.uucp@cs.wisc.edu
Maple Grove Computing               | UUCP:
Madison, WI.                        | ...uwvax!astroatc!maplgrv!vid
(608)273-0950                       |
-- 
     ==================================================================
     ||               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    ||
     ==================================================================

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

From: bill@ksr.com (Bill Mann)
Subject: Re: Malformed cmd links
Date: 12 Oct 92 09:43:49 EDT

| mcook@fendahl.dev.cdx.mot.com (Michael Cook) writes:
| 
|> Perl says "Malformed cmd links" when my script finishes.  Has anyone seen
|> this before?  Any ideas what it might mean?
| 
|> This is perl, version 4.0
| 
|> $RCSfile: perl.c,v $$Revision: 4.0.1.7 $$Date: 92/06/08 14:50:39 $
|> Patch level: 35
| 
| This script exhibits the problem:
| 
| #! /usr/local/bin/perl
| &foo;
| sub foo
| {
|    local (*glob);
| 
|    *glob = "bar";
|    &glob;
| }
| sub bar
| {
|    return;
| }
| __END__
| 
| If I take out the "local (*glob)" or the "return;", I stop getting the
| "Malformed cmd links" message.

I tried to post the following a few weeks ago, I'm not sure it got out:

There have been several complaints during the past few months about
the warning message 'Malformed cmd links'.  This message occurs when
redefining a subroutine where the old definition includes the 'return'
statement.  This problem first appears in 4.035.

As I read the code, there is no real bug, just a spurious warning in
this case.  An otherwise-unused variable is not being initialized
properly.  The following patch fixes the problem for me:

*** ../perl4/cons.c     Thu Aug 13 08:29:39 1992
--- ./cons.c    Wed Sep 23 13:18:38 1992
***************
*** 85,90 ****
--- 85,91 ----
            Nullarg,mycompblock));
        saw_return = FALSE;
        cmd->c_flags |= CF_TERM;
+       cmd->c_head = cmd;
      }
      sub->cmd = cmd;
      if (perldb) {
--

Bill Mann
bill@ksr.com (ksr!bill@uunet.uu.net)

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

From: Tom Christiansen <tchrist@convex.COM>
Subject: Re: Malformed cmd links
Date: Mon, 12 Oct 1992 15:39:08 GMT
Reply-To: tchrist@convex.COM (Tom Christiansen)

From the keyboard of bill@ksr.com (Bill Mann):
:There have been several complaints during the past few months about
:the warning message 'Malformed cmd links'.  This message occurs when
:redefining a subroutine where the old definition includes the 'return'
:statement.  This problem first appears in 4.035.
:
:As I read the code, there is no real bug, just a spurious warning in
:this case.  An otherwise-unused variable is not being initialized
:properly.  The following patch fixes the problem for me:

Well, I can make the warning go away, but plum and pcops still both dump
core at 4.035; maybe it's my coding style. :-) It seems to have something
to do with using eval/die in nested catch/throw constructs.  Larry promises
it'll at least be DIFFERENT in perl5, because the interals of that
entire mechanism will be quite different.

--tom
-- 
    Tom Christiansen      tchrist@convex.com      convex!tchrist
    In general, if you think something isn't in Perl, try it out, because it
    usually is.  :-)
            --Larry Wall in <1991Jul31.174523.9447@netlabs.com>

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

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

From the keyboard of sfy@koel.mel.dit.CSIRO.AU (Shane Youl):
: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.

Current patch:

    for (sort {$Table{$a} <=> $Table{$b}} keys %table) {
	print  "key of $_ is $Table{$_}\n";
    } 

Previous patch:

    for (sort {$Table{$a} <=> $Table{$b};} keys %Table) {
	print  "key of $_ is $Table{$_}\n";
    } 

Long ago:

    for (sort bynumvalue keys %Table) {
	print  "key of $_ is $Table{$_}\n";
    } 
    sub bynumvalue {
	$Table{$a} <=> $Table{$b};
    } 

Really long ago:

    sub bynumvalue { $Table{$a} <=> $Table{$b}; } 
    for (sort bynumvalue keys %Table) {
	print  "key of $_ is $Table{$_}\n";
    } 

Generically:

    for (&sort_keys_by_numvalue(*Table)) {
	print  "key of $_ is $Table{$_}\n";
    } 
    sub sort_keys_by_numvalue {
	local(*dummy) = shift;
	sort bynumvalue keys %dummy;
    } 
    sub bynumvalue { $dummy{$a} <=> $dummy{$b}; } 

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

Perle, plesaunte to prynces paye/ To clanly clos in golde so clere,
Oute of oryent, I hardyly saye/ Ne proued I neuer her precios pere.

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

From: weingart@inf.ethz.ch (Tobias Weingartner)
Subject: ARGV parsing
Reply-To: weingart@inf.ethz.ch
Date: Mon, 12 Oct 1992 15:08:35 GMT

Hello all. ;)

I have a quick question.  I find myself doing a lot of this type
of code at the front of my scripts.  I would like it if someone
could show me a better way to do this...

NOTE:  Using getopt.pl is not an option.

if(@ARGV){
	while($i = shift(@ARGV)){
		if($i =~ m/^-s$/){
			$var = shift(@ARGV);
		}

		if($i =~ m/^-server$/){
			$var = shift(@ARGV);
		}

		die "Unknown option $i.\n";
	}
}

Basically, I would like to re-write the two if statements into
one.  Something like:

if(@ARGV){
	while($i = shift(@ARGV)){
		if($i =~ m/^-s[e]?[r]?[v]?[e]?[r]?$/){
			$var = shift(@ARGV);
		}

		die "Unknown option $i.\n";
	}
}


Can this be re-written in a cleaner fashion?

--Toby.


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

From: Tom Christiansen <tchrist@convex.COM>
Subject: Re: question about perl patterns
Date: Mon, 12 Oct 1992 15:47:05 GMT
Reply-To: tchrist@convex.COM (Tom Christiansen)

From the keyboard of kumar@phage.cshl.org (Sanjay Kumar at Cold Spring Harbor Lab):
: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.

You can't do 

    index($str, /pattern/);

although I've seen people try.  :-(

Use $`, $&, and $':

    if (/pattern) {
	($pre, $match, $post) = ( $`, $&, $' );
    } 

and now you can take the length($pre) to figure out the
numeric position.

--tom
-- 
    Tom Christiansen      tchrist@convex.com      convex!tchrist
I've never professed to be anything but an average student.
		--Vice President Dan Quayle during the 
                   VP debate in Omaha, Nebraska (10/88)

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

** 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
******************************