From: "Benjamin M. A'Lee" Date: 2007-11-16T07:16:33+09:00 Subject: Re: Using a variable with gsub & sub --PmA2V3Z32TCmWXqI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 16, 2007 at 06:34:16AM +0900, Peter Vanderhaden wrote: > In the following statement, I'm replacing ,, with ,NULL,. >=20 > $inrec =3D $inrec.sub(',,\\',',NULL,') >=20 > What I want to do is something like this: >=20 > $inrec =3D $inrec.sub(',,\\',',$variable,') >=20 > Unfortunately, I haven't been able to figure out the syntax for using a > variable with sub & gsub. Can someone help me out? > Thanks. The replacement is simply a string, so you could do: $inrec =3D $inrec.sub(',,\\',','+$variable+',') or $inrec =3D $inrec.sub(',,\\',',#{$variable},') --=20 Benjamin A'Lee :: benjamin.alee@subvert.org.uk Subvert Technologies :: http://subvert.org.uk/ --PmA2V3Z32TCmWXqI Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) iD8DBQFHPMU4EUZDNrttL6ARAuxYAKCz1HdVbB4wgVkM0aDtjrnO8hWEOQCgrBL2 uiuS9qNql0tTSAptx3vDIrw= =UTUx -----END PGP SIGNATURE----- --PmA2V3Z32TCmWXqI--