Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!snorkelwacker!apple!usc!elroy.jpl.nasa.gov!ames!uhccux!munnari.oz.au!frankland-river!pem From: pem@frankland-river.aaii.oz.au (pem) Newsgroups: comp.lang.perl Subject: Weird grep bug ? (perl 3.0 pl8) Message-ID: <845@frankland-river.aaii.oz.au> Date: 19 Jan 90 04:01:29 GMT Organization: Australian AI Institute Lines: 46 I have noticed what seems to be a strange bug in grep. I am not quite sure what is going on -- the problem seems only to occur when I use a 'do ' statement to include a header. I was wondering if anyone else has seen this something like this before. Here is a small program which demonstrates the problem on my machine: (a sun 3/60 running perl 3.0 pl8) All it does is use the built in grep command to match at the start of an array of lines, returning a new array of matching lines. If I include 'getopts.pl', for example, the grep (wrongly) matches every line. Otherwise it works as I would have expected. -----------cut here----------- #!/usr/bin/perl # comment the next line and the program behaves fine! do 'getopts.pl'; $" = "\n"; @dump_lines = ( "f:/, 0", "f:/usr, 1", "h:/, 3", "h:/usr, 4", "f:/, 5", "f:/usr, 6", "h:/, 7", "h:/usr, 8" ); for (;;) { print "\n(note: if you type 'f' you would expect to get only 4 matching lines)\n"; print "Which dump ? (name eg. 'f' or '?' or 'q' to quit) "; chop($_ = ); if (/^[Qq]$/) {exit 0;} elsif (/^\?$/) {print("@dump_lines"); next;} /^\s*(\S+)/; @entry = grep(/^$1/, @dump_lines); print "found the following entries in the log:\n@entry\n"; } ------------------ Paul E. Maisano Australian Artificial Intelligence Institute 1 Grattan St. Carlton, Vic. 3053, Australia Ph: +613 663-7922 Fax: +613 663-7937 Email: pem@aaii.oz.au