in reply to Assistance fixing a "format" call

Any suggestions on where it is I'm going wrong with this?

Well, you posted code which isn't complete and which doesn't demonstrate your bug :) I see you took a page out of Basic debugging checklist, and that is a good step towards asking a question effectively, but as you can see from my complete snippet, what you've shown so far demonstrates no bug

#!/usr/bin/perl -- use strict; use warnings; my @stuff; push @stuff, [ qw[ TECH SCANNER WEBSERVER TALKTOME TRAINING ] ]; push @stuff, [ qw[ TESTING MOBILE TECHADMIN CIRCADMIN MANAGERS ] ]; for my $row ( @stuff ){ my @rows = @$row; print "@rows\n"; format STDOUT = @<<<<<<<<<<<< @<<<<<<<<<<<< @<<<<<<<<<<<< @<<<<<<<<<<<< @<<<<< +<<<<<<< @rows . write; } __END__ TECH SCANNER WEBSERVER TALKTOME TRAINING TECH SCANNER WEBSERVER TALKTOME TRAINI +NG TESTING MOBILE TECHADMIN CIRCADMIN MANAGERS TESTING MOBILE TECHADMIN CIRCADMIN MANAGE +RS

Replies are listed 'Best First'.
Re^2: Assistance fixing a "format" call
by bobdabuilda (Beadle) on Apr 02, 2012 at 06:16 UTC

    Hi Anon, thanks for your response. Thanks very much also for the pointer to the debugging checklist - that's one I'd not come across before, so I've bookmarked that one to refer back to later... could come in very handy, methinks.

    With regard to your comment about the incomplete code - I just took the snippet out of my script that was being problematic - the section before it simply populates the array with the data (which I confirmed good in previous tests, and provided an example of above). Should I have provided more in order to give better context to the issue or...?

    Please note - not trying to be defensive or snarky here - I'm new to posting to the site, and have been trying to ensure I get/do things right so as to not offend the locals. Appears I may have missed the mark this time around ;)

    I'll have to go back later and look at my older version of the script to see if I can work this out - due to time constraints I've moved on from that in the mean-time and have, as suggested, ditched the format stuff and moved on to printf, which is doing the job admirably.

      When you present code here, the best is to give us something that is as short as possible, that actually runs and that reproduces the problem. I didn't run your two "format" code examples because it was "too much effort" - make it easy for us to click, download and run. Otherwise there is some guesswork involved.

      If you have a single file that you use, use a __DATA__ segment for that data. That file handle is already "open" and you can access it:  while(<DATA>){..}.

      I actually ran the code that I gave you and I know that it at least runs on my machine. Please give us the same in return.

      If some code is not working, give us the exact code (preferably something that we can run easily) and the exact error message - don't give us the short explanation like you'd give your 35th cousin in Chickenblister, Wyoming where-ever the heck that is! Get down and dirty with the details!

      If you look at my first answer to your post, you will see that it is a complete runnable program, including a __DATA__ segment. This "=" in column one (eg =prints) is a "trick" - its actually a use of POD - Plain Old Documentation. I often use that in Monk posts so that I can put some comments (like the actual program output) in the code without interfering with the program or its __DATA__ segment. For code without a __DATA__ segment, you can just put __END__ and all after that are just comments (doesn't matter to Perl).

      Having said that, welcome to Monks!

        Marshall, thanks very much for the welcome, and the nice informative responses - very much appreciated!!

        One question for you (I'm in the process of writing up another question, and am working on the example code, and need to do some tweaking in order to make it runnable in it's current reduced format) regarding the __DATA__ tag. Is there a way to emulate a second data source? I notice you said if there's a single file that you use... if it's more than one, can you use, perhaps __DATA2__ to emulate the second file??