Each column is separated by one or more white space. so my code should + look something like this,
Why do you think it should look like that?
$ENV{HOME}='C:\Documents and Settings\kompeS\Desktop\PERL SCRIPTS';
Why are you using $ENV{HOME} to store the directory name? Why not just use a normal lexical variable?
open (FILE,"$file"); close(FILE);
Why are you opening and then closing the file? You should always verify that the file opened correctly.
tie (@data,'Tie::File',$file, mode=>O_RDWR) or die "Can't tie to $file +:$^E\n";
The default mode is already O_RDWR? You should store the object returned from tie so that you can use it later for defer() and flush().
@list=split(/ /,@data);
split's second argument is a scalar so perl will convert @data to a scalar which will be the number of elements in @data. Since there is no whitespace in a number that has the same effect as doing @list = scalar @data;.
You are iterating over the array @data which means that the current line is in the $_ variable.
The regular expression / / will split on a single space character, if you want to split on multiple space characters use / +/ or just use the default @list = split; which will split on multiple whitespace characters.
In reply to Re: Problem with split and file processing. Need Help!!!
by jwkrahn
in thread Problem with split and file processing. Need Help!!!
by sas429s
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |