Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!bloom-beacon!bu.edu!nntp-read!jbw From: jbw@bucsf.bu.edu (Joe Wells) Newsgroups: comp.lang.perl Subject: perl bug with $1, affected by subroutine call Message-ID: Date: 6 Mar 90 02:55:26 GMT Sender: news@bu.edu.bu.edu Organization: Boston University Computer Science Department Lines: 41 When the this short perl program is run: &one(&sub1); &sub1; sub one { 1; } sub sub1 { if ('x' =~ m/(x)/) { print "sub1 1: $1\n"; } } I get this as output: sub1 1: sub1 1: x Would anyone happen to know why $1 is not getting set properly in &one(&sub1)? I've tried these variations, and they all work correctly: sub sub2 { if (('x' =~ m/(x)/) && 1) { print "sub2 1: $1\n"; } } sub sub3 { if ('x' =~ m/(x)/) { print "sub3 1: $1\n"; } 1; } sub sub4 { 'x' =~ m/(x)/; print "sub4 1: $1\n"; } Thanks! -- Joe Wells jbw%bucsf.bu.edu@cs.bu.edu ...!harvard!bu-cs!bucsf!jbw