Awk question

Tom Christiansen tchrist at convex.COM
Mon Jan 21 10:21:54 AEST 1991


>From the keyboard of jay at 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.  I guess that's the price you pay for
not having variable markers as you do in the shell or perl.  Certainly in
perl there's a big difference between

    if ($myarray[$i] =~ /foo/)	# can't use ~ -- that's bitwise negation, per C
and
    if ($myarray[$i] =~ /$foo/)

I shall say no more. :-)

--tom
--
"Hey, did you hear Stallman has replaced /vmunix with /vmunix.el?  Now
 he can finally have the whole O/S built-in to his editor like he
 always wanted!" --me (Tom Christiansen <tchrist at convex.com>)



More information about the Comp.unix.shell mailing list