indexing versus pattern matching, or combining the two 
Author Message
 indexing versus pattern matching, or combining the two

Sometimes, I'd like to be able to know the starting positions of
matched strings $1, $2, and so on.  This can be computed as
length($'), sometimes.  But I'd like to get a position on each of the
matched expressions without doing further computation.  It seems that
the information is somewhere inside Perl.  Anyone has ideas,
suggestions?

BTW, anyone has a perl script that computes gnuemacs style tags?

ZWC



Sun, 28 Jul 1996 05:45:23 GMT  
 indexing versus pattern matching, or combining the two

: Sometimes, I'd like to be able to know the starting positions of
: matched strings $1, $2, and so on.  This can be computed as
: length($'), sometimes.  But I'd like to get a position on each of the
: matched expressions without doing further computation.  It seems that
: the information is somewhere inside Perl.  Anyone has ideas,
: suggestions?

Not offhand.  The info is in there all right, but you can't get at it
easily without a peek function.  I can see where it might be useful in
some cases.  But to put this in perspective, you're the first person
who has ever asked for this, as far as I can recall.  Which seems to
indicate that the feature is not in great demand.

Larry



Mon, 29 Jul 1996 03:38:54 GMT  
 indexing versus pattern matching, or combining the two

Quote:

> : Sometimes, I'd like to be able to know the starting positions of
> : matched strings $1, $2, and so on.  This can be computed as
> : length($'), sometimes.  But I'd like to get a position on each of the
> : matched expressions without doing further computation.  It seems that
> : the information is somewhere inside Perl.  Anyone has ideas,
> : suggestions?

> Not offhand.  The info is in there all right, but you can't get at it
> easily without a peek function.  I can see where it might be useful in
> some cases.  But to put this in perspective, you're the first person
> who has ever asked for this, as far as I can recall.  Which seems to
> indicate that the feature is not in great demand.

> Larry

Well, actually, I would have liked this feature many a time. Having to
parse meteorological data with possible corruptions would be easier
with a regexp returning/indicating where we found matches. The regexps
get pretty messy as it is.

I perhaps should have asked earlier but had thought that Perl4.036 was
the last "4" and that my modest requirements should not disturb those
power people talking way above my head about the new improved Perl 5
facilities.

Seeing as it has been mentioned once, is it possible to have some
mechanism - some more variables ?! - to get the posititions.

Thank you Mr. Wall,

Humbly,

Adrian

--
---------------------
 ========================================================================
=                                                                        =
= Adrian Phillips at The Norwegian Meteorological Institute              =
=                                                                        =
= BUT any thoughts in this are purely my own and have nothing to do with =
= this establishment, thankfully.                                        =
=                                                                        =

= Phone: 47 22 96 32 09                                                  =
= Fax: 47 22 96 30 50                                                    =
=                                                                        =
 ========================================================================



Mon, 29 Jul 1996 18:58:42 GMT  
 indexing versus pattern matching, or combining the two


: > : Sometimes, I'd like to be able to know the starting positions of
: > : matched strings $1, $2, and so on.  This can be computed as
: > : length($'), sometimes.  But I'd like to get a position on each of the
: > : matched expressions without doing further computation.  It seems that
: > : the information is somewhere inside Perl.  Anyone has ideas,
: > : suggestions?
: >
: > Not offhand.  The info is in there all right, but you can't get at it
: > easily without a peek function.  I can see where it might be useful in
: > some cases.  But to put this in perspective, you're the first person
: > who has ever asked for this, as far as I can recall.  Which seems to
: > indicate that the feature is not in great demand.
: >
: > Larry

Semi related but...

What I would like to see is some why to know the index in the array when I do
a foreach.



Quote:
}

I know I can do a for($i=0; $i<=$#files
but that is ugly.

--
--------
Wayne Scott



Wed, 31 Jul 1996 00:52:35 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. combine two pattern matches to one match?

2. Pattern matching of a large dbm file (slow indexing)

3. Combining two files into a two-column file

4. Matching two patterns at once

5. Pattern matching spanning more than one line and substitution between two files -

6. pattern matching across two lines

7. pattern matching across two lines

8. Matching two patterns in a DB. (general expressions...)

9. Perl and Javascript - combining the two

10. How to combine two images.

11. Combining two @array's

12. Help combining two files.

 

 
Powered by phpBB® Forum Software