Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!van-bc!ubc-cs!phillips From: phillips@cs.ubc.ca (George Phillips) Newsgroups: comp.lang.perl Subject: regexp and slice bugs Summary: help! Message-ID: <8483@ubc-cs.UUCP> Date: 29 Jun 90 08:32:25 GMT Sender: news@cs.ubc.ca Organization: University of British Columbia, Vancouver, B.C., Canada Lines: 33 Under perl 3.0, patchlevel 18, the following script gives a wrong answer: $block = "a\nd"; print $block =~ /^d/; print "\n"; print $block =~ /^\144/; print "\n"; The second regexp matches. It seems like the bug is in scanconst() since it doesn't understand octal escapes and therefore doesn't give the right answer to scanpat(). On the other hand, scanconst() may not be to blame but its minor failure lets a bug crawl out of somewhere else. The other bug can come up in many ways, but you can reproduce it (and a core dump) with: @out[0] + 1; I haven't found a fix here either, but it seems that the array slice routine ends up returning a NULL pointer for the single element slice ('cause that's what afetch() returned). Add blindly converts the top two stack elements to numbers and crashes when it hits the NULL. Maybe do_slice() shouldn't put Nullstr on the stack or maybe add (and others) should be more careful. Who knows? Larry! Guide us! A challenge: produce some useful code that gets killed because of the array slice "bug" (bonus points if its output is you-know-what). The best I could do was: perl -D14 -e 'foreach $f (@out[1..3]) { print $f + 1; }' But that runs if you turn off debugging. George Phillips phillips@cs.ubc.ca {alberta,uw-beaver,uunet}!ubc-cs!phillips