RE: Perl Script
by "Shaun L. Sides" <arch(at)charter.net>
|
| Date: |
Wed, 28 Jun 2000 17:00:06 -0400 |
| To: |
hwg-languages(at)hwg.org |
| In-Reply-To: |
network |
| |
todo: View
Thread,
Original
|
|
-----BEGIN PGP SIGNED MESSAGE-----
On 28 Jun 2000, at 10:05, Peter Benoit wrote:
> I've really no clue what yer doing on that $number =~ line
The =~ operator basically applies the regex to the scalar, and then
stores the result back in the scalar again.
As the Camel has it, "Binary =~ binds a scalar expression to a
pattern match, substitution, or translation."
You can modify the $_ string without having to explicitly use the
operator:
$_ = "1234567890";
s/(\d{3})(\d{3})(\d{4})/\($1\)-$2-$3/;
Now $_ contains "(123)-456-7890"
You can also display the result of the binding directly by using
something like:
$_ = "1234567890";
print s/(\d{3})(\d{3})(\d{4})/\($1\)-$2-$3/;
As always, TMTOWTDI. ;-)
-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.2 -- QDPGP 2.61a
Comment: http://community.wow.net/grt/qdpgp.html
iQCVAwUBOVpnVSEw9uEAOtM/AQFsgQP/dcHL2Fx/Kx0PM4AaP0nZyWy4i+mPsk9h
s0r2HADCtq1SOonFVN/nASr/eNnVOB4JoUtFryi0PZf63Zp+nAQpF3rN5m0zpGJf
/jyqizf+Wol0WANwv4RX/0GqoFX+j67KbekiCeRGvv044hyJOwgyKL+OFwNABZjN
S+c801pybFY=
=1iiL
-----END PGP SIGNATURE-----
HWG: hwg-languages mailing list archives,
maintained by Webmasters @ IWA
This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.