Jump to content

Update a configuration file: Difference between revisions

→‎{{header|Perl 6}}: fix bug & copy-paste'o
(add Perl 6 solution)
(→‎{{header|Perl 6}}: fix bug & copy-paste'o)
Line 1,345:
next if !$1 or %seen{$1.uc}++;
my $new = %changes{$1.uc}:delete;
say $out: format-line $1, |( !defined($new) ~~ Bool ?? ($2, !$new0) !! ($new//$2, True));
$new ~~ Bool ?? ($2, $new) !! ($new, True) );
}
default {
Line 1,353 ⟶ 1,354:
}
say $out: format-line .key, |(.value ~~ Bool ?? (42Nil, .value) !! (.value, 42True))
for %changes;
Line 1,359 ⟶ 1,360:
}
 
END { unlink $tmpfile if $tmpfile.IO.e }</lang>
 
 
sub format-line ($key, $value, $enabled) {
("; " if !$enabled) ~ $key.uc ~ (" $value" if defined $value);
}
 
sub tmpfile {
$*SPEC.catfile: $*SPEC.tmpdir, ("a".."z").roll(20).join
}</lang>
 
=={{header|PicoLisp}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.