No such thing as a small change | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I'm trying to print the content of the array that contains the indexes/positions before and after
{LAST_MATCH_START/@- LAST_MATCH_END/@+} where the /\t+/ regex matched within the read input string $_ for example the following input file foo bar baz foo bar foo baz ccc ddd foo bar foo baz ccc ddd foo bar baz foo bar foo baz ccc ddd fooshould print -1 -1 11 12 11 12 23 24 27 28 31 32 11 13 24 27that is 0 based positions where TABs \t occur in the input file each TAB having a begin end position NOTE:
line 2 prints "11 12" TABs \t as this is the 0 base index/position of the start/end of the only TAB \t on that line line 3 prints "11 12 23 24 27 28 31 32" as this is the 0 base indexes/positions of the start/end of the 4 TABs \t on that line line 3 have one adjecsent TABs,that is,there is only 1 TAB between words foo and baz,ddd and foo,foo and bar,bar and baz line 4 prints "11 13 24 27" as this is the 0 base indexes/positions of the start/end of the 4 TABs \t on that line line 4 have more than 1 {>1 >=2} one adjecsent TABs,that is,there is more than 1 {>1 >=2} one TABs between words foo and baz,ddd and foo,foo and bar,bar and baz 11 12 11 12 11 13NOTE:
11 12 31 32 37 42 NOTE:
where the regex matched within the read input string $_ using $-[] and $+[] (lines 6 and 7) here is the code NOTE:
I then searched google "perl regex LAST_MATCH_START/@- LAST_MATCH_END/@+ bug" and found https://github.com/Perl/perl5/issues/16109 that says its not a bug It would be very helpful if someone could explain what's going on and how to print the right indexes/positions where TAB \t occurs thank's In reply to printing LAST_MATCH_START/@- LAST_MATCH_END/@+ array where regex match begin/end by perl_boy
|
|