in reply to Re^4: divide multi-column input file into sub-files depending on specific column's value
in thread divide multi-column input file into sub-files depending on specific column's value

I can't see anything wrong with your printf statement, and it works for me:

open $FORM, '>', 'column.FORM' or die $!;; @c = (1.2, 1.3, 1.4, 1.5); $t = '%10s'x@c . "\n"; printf( $FORM $t, @c );; close $FORM;; ^C C:\test>type column.FORM 1.2 1.3 1.4 1.5

so what is going wrong I have no idea.

Equally your comment, #chomp; # this gives me syntax errors??? makes no sense, chomp; cannot be a syntax error.

Your comments in an earlier thread to the effect of "I don't know why it didn't work before but it does now", all suggest that the way you are writing your code; or running your scripts, or some other environmental factor is causing you to experience problems that are not down to Perl, or the code you are posting.

The upshot is, I'm going to suggest that you try to seek out someone local to you with some programming knowledge to watch you write and run a small, simple program and perhaps he will see the problem that we cannot see when interacting with you this way.

A final comment on your script above: You do know that:$columns[$#columns] is a single value?

If so, why are you using a foreach loop to iterate over a single value?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re^5: divide multi-column input file into sub-files depending on specific column's value
  • Select or Download Code

Replies are listed 'Best First'.
Re^6: divide multi-column input file into sub-files depending on specific column's value
by angela2 (Sexton) on Jul 05, 2016 at 16:23 UTC

    Thank you for the information and suggestions. It's a bit complicated but I found myself doing lots of coding without expecting to and nobody has the time to explain stuff because, of course, they have their own work to do and can't really give me any more time than they already have. The tricky bit is that the (indeed huge) help I received was just me being a backseat coder - which although it helped tremendously in terms of the project progressing, it couldn't do much in terms of me actually learning to code. I did learn to avoid syntax errors, I did learn to do some things, I can write some stuff but I lack proper knowledge and it's not possible to get more support at this stage. All I can do is google and ask questions - and produce dubious code, unfortunately.

    Anyway. No, I didn't realise I was looping through a single value. I was under the impression (or at least hoping) that I was looping through all values of the last column. And this is where disappointment and tiredness kicks in - I've been "refining" (lol) a piece of code for 10 straight hours and in the end it's completely wrong and doing something weird - and I don't even know what it's doing if it's looping through a single value! In any case thank you very much for the contributions, time and patience.

      "I've been "refining" (lol) a piece of code for 10 straight hours and in the end it's completely wrong and doing something weird - and I don't even know what it's doing"

      That's how we all get started, if you get through this part that's an important part of becoming good at programming :-) My recommendation if it gets too frustrating is to take a break from coding and read the docs :-) perlintro