# New Ticket Created by  Matt Diephouse 
# Please include the string:  [perl #37949]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=37949 >


Can you guess what the following prints (hint: read the subject):

   .sub main :main
     $P0 = new .String
     $P0 = "Foo"

     $S0 = $P0
     substr $S0, 0, 1, "B"

     print $P0
     print "\n"
   .end

It prints "Boo\n". Modifying $S0 also modifies $P0 because the String  
PMC get_string method returns the internal string pointer instead of  
making a copy. Bad Parrot!

--
matt diephouse
http://matt.diephouse.com

Reply via email to