in reply to Re: Add whitespace in middle of string (substr?)
in thread Add whitespace in middle of string (substr?)
The reason your attempt at substr doesn't work, this part
while (my $elements[20] = <INFILE>) { substr $elements, 7, 0, ' '; }
is simple, files are iterators, once you read the whole file, this part of your code @infile=<INFILE>;
you're at the very end, there is no more file left to read
Also that is a syntax error
You probably meant to write
substr $elements[20], 7, 0, ' ';
You ought to give perlintro another read
if ($#ARGV != 1) {print "usage: input-file output-file \n";exit;}
In perlish perl we write that as :)
@ARGV or die "Usage: $0 input-file output-file\n";
You can write it as if( @ARGV ){ die "Usage: $0 input-file output-file\n"; } if you're attached to if(){}
|
|---|