----- Original Message -----
From: "chen li" <[EMAIL PROTECTED]>
[snip]
I think it might be natural for me to read the file
line by line and get the return position looks like
these(just an example), similar to do the word search
in microsoft Word, which is what I really want:
match in line 1 and the end of matching position is 4
match in line 4 and the end of matching position is 24
I think this is what you want.
You may want to read:
perldoc -f pos
perldoc perlvar (look for @- and @+ variables, LAST_MATCH_START and
LAST_MATCH_END, respectively)
Chris
#!/usr/bin/perl
use strict;
use warnings;
while (<DATA>) {
chomp;
while (/\bchen\b/g) {
print "match in line $. and the end of matching position is
",pos,"\n";
}
}
__DATA__
this chen has a chen
xxxxx
tyre
brit chen is good
*** Output
C:\perlp>perl t5.pl
match in line 1 and the end of matching position is 9
match in line 1 and the end of matching position is 20
match in line 4 and the end of matching position is 9
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>