Brent Dax wrote:
Can the new nefarious use be concat? Pretty please?
On Wednesday, October 23, 2002, at 07:46 PM, Damian Conway wrote:
On behalf of the Dumb People, I object. :-)... When I'm training newcomers to Perl, one of the hardest things for them to get is the =~ operator doing a regex. Regexen aren't a base part of most languages that beginning programmers use, but it's an integral part of Perl. Noone ever guesses that =~ means "matching": it looks like an assignment, which it sometimes is, and sometimes isn't, etc. It takes a lot of explaining, and even then people have often written ~= when they mean =~, and stared at it for a half hour not knowing why it didn't work.I guess the only concern is the potential for nasty surprises between: $str =~ s/a/b/; substitute a for b in $str and: $str ~= s/a/b/; substitute a for b in $_ and append result to $str
So I think the =~ vs ~= would be very, very confusing to people, just because =~ is already very confusing to start with, which, in turn, implies we can't use ~ for concat.
If anything, I'd almost suggest the other way around, such that ~ means matching and ~= means matching assignment:
$str1 ~ $str2 # $str1 =~ m/$str2/
$str ~ /foo/ # $str1 =~ m/foo/
$str2 = ($str ~ /foo/bar/); # perform subst, assign result to $str2
$str ~= /foo/bar/; # perform subst, assign result to $str
.... which sortof goes better with the new 'magic matching' usage of =~, and I could make some vague argument for matching +=, etc. IF we want to muck with it at all.
MikeL