Mercurial > octave
view build-aux/inplace_edit.pl @ 31603:23520a50d74d stable
maint: Review C++ files for style and coding conventions.
* __ftp__.cc (F__ftp_cwd__, F__ftp_mget__),
__isprimelarge__.cc (F__isprimelarge__, F__pollardrho__),
debug.cc (Fdbclear), file-io.cc (Ftempdir):
Don't bother to define nargin if it is used only once in function.
Instead, just call args.length () for the one instance.
* data.cc (fill_matrix): Eliminate useless break statement after error() which
throws exception.
* qr.cc (Fqr),
__ode15__.cc (IDA::integrate, IDA::event, IDA::interpolate, IDA::outputfun):
Use true or false rather than 0 or 1 when assigning to bool variables.
maint: Review C++ files for style and coding conventions.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 30 Nov 2022 20:27:16 -0800 |
parents | 8b548f2f8086 |
children |
line wrap: on
line source
#!/usr/bin/perl -w ################################################################################ ## File: inplace_edit.pl ## Usage: perl inplace_edit.pl 'PERL_CODE' file1 [file2] [...] ## Purpose: Run snippet of PERL_CODE on each line in a file and replace ## existing line with the results of running the code. ## This replaces perl -i -pe 'PERL_CODE' file1 [file2] ... ## due to a problem in Perl 5.28 which restricts the number of files ################################################################################ ## Create Perl code from first argument (-e CODE) eval "sub per_line_code { $ARGV[0]; }"; shift @ARGV; ## Loop over each file foreach $fname (@ARGV) { rename ($fname, "$fname.$$") or die "Rename failed:$fname:$!"; open (my $FHI, "<", "$fname.$$") or die "Open failed:$fname.$$:$!"; open (my $FHO, ">", "$fname") or die "Open failed:$fname:$!"; ## Loop over each line while (<$FHI>) { per_line_code (); print $FHO $_; } close ($FHI); close ($FHO); unlink "$fname.$$" or die "Delete failed:$fname.$$:$!"; }