At 11:01 PM -0600 1/12/12, Chris Stinemetz wrote:
 >
 Define an array with the headers you expect:

 my @headers = ( '>csno', 'rfpi', 'vrp0', ... );

 Use that array for your keys instead of the @header array.

 To avoid warnings of uninitialized values for missing values, print the
 expression (defined $data{$key} ? $data{$key} : '' ) instead of $data{$key}
 or put "no warnings 'unintialized';" inside the print loop.


Thanks again Jim,

I am having a bit of trouble trying to implement your suggestions.

I am getting the following error:

Global symbol "%data" requires explicit package name at
C:\Users\cstinemetz\Documents\Perl\dev\headers.pl line 38.
Global symbol "%data" requires explicit package name at
C:\Users\cstinemetz\Documents\Perl\dev\headers.pl line 38.

I believe it is because (defined $data{$key} ? $data{$key} : '' ) is
for hash notation and not array.

That is correct. If you want to have a lexical hash variable named %data, you must declare it in the appropriate scope in your program with a 'my %data;' statement.

Please keep in mind that when I post program "snippets" like this that you cannot simple include them verbatim in your program and expect them to work and do what you want. They are just examples that must be adapted to your own use. I rarely have the time to provide complete programs that fulfill your requirements, and me writing a complete program is not necessarily the best way to help you. You need to learn from the example given and write your own programs.

Please learn to restrict your emails to the list and not to me directly. Thanks.

--
Jim Gibson
j...@gibson.org

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to