develooper Front page | perl.perl5.porters | Postings from August 2021

for perl 7

Thread Next
August 10, 2021 02:59
for perl 7
Message ID:

I beg you pardon for my poor English.

I have had some little contact with brian d foy and I write to you now! I have a little syntactic suggestion for perl 7. Indeed, I often find myself writing things similar to

if ($foo ne $baz) {$foo = $baz; doSomething};

which is a little verbose for my taste and does not feel syntactically optimally perlish. I do not want (to) "doSomething" if $foo already was equal to $baz since before. Some perlers would probably argue for a construct similar to

doSomething if ($foo ne $baz, $foo = $baz)[0];

but I choose not to call it perlish either. Indeed I would prefer a more concise (and perlish?) syntax similar to

doSomething if ($foo =ne $baz);

where =ne would:

• check if $foo and $baz are different and temporarilly store the result of this comparison "somewhere".

• assign $baz into $foo

• return the result of the comparison previously stored (above)

This syntax would of course also call doSomething if $foo and $baz were different before the line was interpreted.

I suggest not to use the syntax

$foo ne= $baz;

which could risk to be (mis)understood as

$foo = $foo ne $baz;

Thus, if you like the syntactic idea of

doSomething if ($foo =ne $baz);

then feel free to introduce it into Perl 7! ツ You do not need to refer to me and say it was my idea, but if you want to refer to me, that's equally OK.

Of course, this suggestion could be extended to


or similar for numeric comparisons.

Kind regards!


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About