I'll second Bloodnok's suggestion, but take it a bit further.

First off, you probably shouldn't have "my ($id_name, $filename, $last_name, $first_name, $alignment, $generic_class_name, $class_name, $generic_race, $race, $gender, $experience, $strength, $dexterity, $constitution, $intelligence, $wisdom, $charisma) = qw(test) x 17;". You probably should just use a hash: "my %character;", or, if you want to initialise it all, "my %character = map { $_ => 'test' } qw/id_name filename last_name first_name alignment generic_class_name class_name generic_race race gender experience strength dexterity constitution intelligence wisdom charisma/;" (and if you do this, you can use one of the Hash modules to lock the keys, though I don't bother).

Once you do this, then accepting what Text::CSV gives you shouldn't be such a big deal.

What's more, I generally don't use Text::CSV or it's bigger brother, Text::CSV_XS. Well, not directly. I use DBD::CSV (which uses Text::CSV_XS under the covers). By treating your CSV file as a table in a database, some things get a bit easier. Like letting the DBI/DBD code do the looping for you when you want to extract certain character(s). Or just certain elements of the character.

I have to admit ... I'm curious as to why you need Tie::IxHash. Nevermind - you want to control the order that everything comes out, I see that now.

PS: if you want your ability scores, you can just do this:

my %ability_scores = map { $_ => $character{$_} } qw/strength dexter +ity constitution intelligence wisdom charisma/;


In reply to Re: How to set variable names using Text::CSV? by Tanktalus
in thread How to set variable names using Text::CSV? by Lady_Aleena

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.