Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!fciva!dag From: dag@fciva.FRANKCAP.COM (Daniel A. Graifer) Newsgroups: comp.unix.shell Subject: Re: Awk question Message-ID: <585@fciva.FRANKCAP.COM> Date: 21 Jan 91 15:39:53 GMT References: <3094@wyse.wyse.com> <1991Jan20.062150.24582@convex.com> <681@silence.princeton.nj.us> <1991Jan20.232154.29651@convex.com> Reply-To: dag@fciva.UUCP (Daniel A. Graifer) Distribution: usa Organization: Coastal Capital Funding Corp., McLean, VA Lines: 40 In article <1991Jan20.232154.29651@convex.com> tchrist@convex.COM (Tom Christiansen) writes: >From the keyboard of jay@silence.princeton.nj.us (Jay Plett): >:I've never been able to find a way to use a variable on the right-hand >:side of a ~ expression with any of the incarnations of awk. Have I >:missed something? > >Hmm, now that you mention it, there's no way for awk to distinguish > > if (myarray[i] ~ /foo/) > >is the literal or the variable foo. $ nawk 'BEGIN{ x="aw fubar anyways" foo="bar" if ( x ~ foo ) print "Yep" else print "Nope" }' Yep $ nawk 'BEGIN{ x="aw fubar anyways" foo="b.r" if ( x ~ foo ) print "Yep" else print "Nope" }' Yep 'nuff said Dan -- Daniel A. Graifer Coastal Capital Funding Corp. Sr. Vice President, Financial Systems 7900 Westpark Dr. Suite A-130 (703)821-3244 McLean, VA 22102 uunet!fciva!dag fciva.FRANKCAP.COM!dag@uunet.uu.net