while (/<s>/g) 
Author Message
 while (/<s>/g)

The following code should theoretically, take each instance of <s> on a
line and replace it with <slinksbh link="$T"> where $T is the next entry
in an array.

while(/<s>/g) {

  s/<s>/<slinksbh link="$T">/;

Quote:
}

In practice, I find that it doesn't happen that way:

The following is the result of putting print "$T\n$_" after the s/// line: Note especially I.C:40:2:1(1) and following where the while loop seems to be
continuing unexpectedly.

This is Perl 4.something under DGUX.

I.A:40:1:1(1)
<h2><hn2>A<bt2>40001001<et2>40001017<ht2>Jesus' Genealogy:<slinksbh link="I.A:40
:1:1(1)">1,</slinksbh><s>2</slinksbh>
I.A:40:1:1(2)
<h2><hn2>A<bt2>40001001<et2>40001017<ht2>Jesus' Genealogy:<slinksbh link="I.A:40
:1:1(1)">1,</slinksbh><slinksbh link="I.A:40:1:1(2)">2</slinksbh>
I.B:40:1:18(1)
Unusual Events,<slinksbh link="I.B:40:1:18(1)">1,</slinksbh><s>2</slinksbh>
I.B:40:1:18(2)
Unusual Events,<slinksbh link="I.B:40:1:18(1)">1,</slinksbh><slinksbh link="I.B:
40:1:18(2)">2</slinksbh>
I.C:40:2:1(1)
Unusual Events,<slinksbh link="I.B:40:1:18(1)">1,</slinksbh><slinksbh link="I.B:
40:1:18(2)">2</slinksbh>
I.D:40:2:12(1)
Unusual Events,<slinksbh link="I.B:40:1:18(1)">1,</slinksbh><slinksbh link="I.B:
40:1:18(2)">2</slinksbh>
II.A:40:3:1(1)
Unusual Events,<slinksbh link="I.B:40:1:18(1)">1,</slinksbh><slinksbh link="I.B:
40:1:18(2)">2</slinksbh>
II.A:40:3:1(2)
Unusual Events,<slinksbh link="I.B:40:1:18(1)">1,</slinksbh><slinksbh link="I.B:
40:1:18(2)">2</slinksbh>
II.B:40:3:13(1)
Unusual Events,<slinksbh link="I.B:40:1:18(1)">1,</slinksbh><slinksbh link="I.B:
40:1:18(2)">2</slinksbh>
II.B:40:3:13(2)
Unusual Events,<slinksbh link="I.B:40:1:18(1)">1,</slinksbh><slinksbh link="I.B:
40:1:18(2)">2</slinksbh>
Unusual Events,<slinksbh link="I.B:40:1:18(1)">1,</slinksbh><slinksbh link="I.B:
40:1:18(2)">2</slinksbh>

--

909-621-1291                   Coming soon: the Quixote Digital
FAX: 909-625-1342              Typography WWW site.
Quixote Digital Typography



Sun, 23 Nov 1997 03:00:00 GMT  
 while (/<s>/g)


: The following code should theoretically, take each instance of <s> on a
: line and replace it with <slinksbh link="$T"> where $T is the next entry
: in an array.
:
: while(/<s>/g) {

:   s/<s>/<slinksbh link="$T">/;
: }
:
: In practice, I find that it doesn't happen that way:

You're not allowed to modify the string that you're using //g on.
In Perl 4 this is basically undefined, and can have various results
depending on the nature of the modification.  In Perl 5, the manual says

     If you modify the string in any way, the match position is reset
     to the beginning.

You can do what you want with s///eg or with split.

Larry



Mon, 24 Nov 1997 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. <<<<<< HELP >>>>>>>>

2. >>>> A Singaporean Girl looking for more penpals!!<<<<<

3. <<>> COMPUTER SOFTWARE / HARDWARE <<>>

4. - - - = = =<><> W e b - U S A <><>= = = - - -

5. <<>> COMPUTER SOFTWARE / HARDWARE <<>>

6. ==>>COMPUTER HARDWARE / SOFTWARE <<==

7. >>>>>>>>>>>>>> Perl-script archiv wanted <<<<<<<<<<<<<<

8. Perl debugger prompt question <<##>>

9. newbie question regarding s/<old string>/<new string>/g

10. how to bootstrap <name_x>.dll from <non-name_x>.pm

11. <<My Sort Problem>>

 

 
Powered by phpBB® Forum Software