I will only comment on the flaws in script 1, as that deals with Text::CSV

use strict; use warnings; use Text::CSV; use Data::Dumper; open my $io, "<", "player_characters.csv" or die "player_characters.cs +v: $!"; my $csv = Text::CSV_XS->new ({ sep_char => "|", allow_whitespace => 1, blank_is_undef => 1, binary => 1, auto_diag => 1, }); my @names = @{$csv->getline ($io)}; $csv->column_names (@names); while (defined (my $hr = $csv->getline_hr ($io))) { print Dumper ($hr); }

If you do not use the @names after you set it, other than to assign to to column names, you can combine the in one call, as column_names () accepts both a list or a list ref

$csv->column_names ($csv->getline ($io));

Enjoy, Have FUN! H.Merijn

In reply to Re: How to set variable names using Text::CSV? by Tux
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.