Terse vs didactic. Was Re: date format



Bart Van der Donck wrote:

But of course I do like occasional "sport lines" like

$ar[3] =~ s/$m[$_]/@{[sprintf('%02g',$_+1)]}/ for (0..$#m);

in stead of splitting it up in 5 lines or so, like I would rather do in
production code. Just do myself a favour in the future :-)


Yes, so far as I can tell, the above is identical to

my $i = 0;
$ar[3] =~ s/$_/sprintf "%02g",++$i/e for (@m);

using s///e instead of s//@{[]}/
and using the array more like a list.


With didactic variable names ...

my $monthnumber = 0;
foreach my $monthname (@monthnames){
$line =~s/$monthname/sprintf "%02g", ++$monthnumber/e;
};

Which, personally, I do prefer :-)
.