in reply to Re^2: Assistance fixing a "format" call
in thread Assistance fixing a "format" call

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!

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

    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??

      There can be only one __DATA__ segment, however there is another way! Use a heredoc and assign that to a variable, then you can open that variable for reading just like a file! WoW! This is way cool. Note the reference (\$data2) in the open statement.
      #!/usr/bin/perl -w use strict; my $data2 =<<END; This is an example of another way to do this than the DATA segment END open DATA2, '<', \$data2 or die $!; while (<DATA2>) { print; } __END__ Prints: This is an example of another way to do this than the DATA segment
      Note that it is also possible to open a variable for writing! This is handy sometimes to avoid making a temporary file that you have to delete.