develooper Front page | perl.perl6.internals | Postings from October 2001

substr broken?

Thread Next
Brian Wheeler
October 16, 2001 09:53
substr broken?
Message ID:
I'm getting some weird results when using substr.  Here's my test

	set	S0,"Hello world"
	print	"Arg to Reverse: "
	print	S0
	print	"\n"
	set	S1,""
	set	S2,""
	length	I0,S0
	dec	I0
$loop:	substr	S2,S0,I0,1
	print	"string so far:"
	print	S1
	print	", "
	print	S2
	print	"\n"
	concat	S1,S2
	dec	I0
	ge	I0,0,$loop
	set	S0,S1

Here's the output:
Arg to Reverse: Hello world
string so far:d, d
string so far:l, l
string so far:r, r
string so far:o, o
string so far:w, w
string so far: ,  
string so far:o, o
string so far:l, l
string so far:l, l
string so far:e, e
string so far:H, H

Why is S1 set on the first iteration, before the concat?


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About