in reply to Reformat file with empty spaces

Use substr

#!/usr/bin/perl use strict; my $infile = 'infile.txt'; my $outfile = 'outfile.txt'; open my $in,'<',$infile or die "Could not open $infile : $!"; open my $out,'>',$outfile or die "Could not open $outfile : $!"; while (<$in>){ chomp; my $spaces = substr($_,39,5); if ( $spaces eq ' '){ substr($_,5,5,''); $_ .= $spaces; } print $out "$_\n"; } close $in; close $out;
poj

Replies are listed 'Best First'.
Re^2: Reformat file with empty spaces
by Anonymous Monk on Jan 11, 2018 at 09:54 UTC
    Thanks a million Poj !