Perl Code Question

Steve Johnson steve at bbdltd.com
Tue Jan 11 09:46:10 CST 2000


^ means match the beginning of a string or line, if $* set: See "Regular
Expressions" in the camel book, page 103 in my edition.


> -----Original Message-----
> From: owner-grand-rapids-pm-list at pm.org
> [mailto:owner-grand-rapids-pm-list at pm.org]On Behalf Of Ed Eddington
> Sent: Tuesday, January 11, 2000 10:29 AM
> To: 'grand-rapids-pm-list at happyfunball.pm.org'
> Subject: Perl Code Question
>
>
> This is bugging me. I know that this works, but don't know why.
> Below is an
> example search/replace that swaps the first 2 terms separated by a space.
> The '^' here is performing some kind of "not" or "anything but" a
> space in
> both of the [] terms. I have used this in code, but have never found this
> usage of ^ in the Perl docs. Can someone explain what this '^' is doing?
>
> s/([^ ]*) *([^ ]*)/$2 $1/;            # reverse 1st two fields
>
>
>
>
> Thanks!
> Ed
>
>




More information about the grand-rapids-pm-list mailing list