in reply to ideas on how to improve existing code

It is not clear why you are diddling the data, what you call "format the columns", so why are you? You should do that after parsing into cvs, not before

Somehow I have a feeling that this code is not efficient but it works.

Thats just gas, don't worry about it

Is it worth to improve it or just use it as it is?

The code is literally 20 lines, there is nothing to improve

The only possible thing is use "modern perl" practices, meaning use 3 argument open, and lexical filehandle, and maybe use autodie because the error message is better

$ perl -Mautodie -le " open my $fh => '<', '23232' " Can't open '23232' for reading: 'No such file or directory' at -e line + 1

Replies are listed 'Best First'.
Re^2: ideas on how to improve existing code
by trolis (Novice) on Aug 29, 2011 at 09:31 UTC
    Thanks for reply and comments.

    My initial goal is to set up those files to the default format which gnuplot accepts (space delimited columns of data with a dot as decimal separator). I have many csv files which all look slightly differently so the idea was to make them all "the same". For sure there could be many other ways to complete the task but somehow I have chosen Perl. The script should grow over time as I plan to implement more features but I have just started.