I feel your intrigue, my man. If you're trying to do this for your own fun- go for it.

The code hack beneath is a start to doing it from scratch, keep in mind this code is untested.:

my @fieldname = ('one','seat','three'); =pod the structure we are aiming for might be: @lines = ( { $fieldname => $value, $fieldname => $value, $fieldname => $value, }, { $fieldname => $value, $fieldname => $value, $fieldname => $value, }, { $fieldname => $value, $fieldname => $value, $fieldname => $value, }, ); thus.. line 3 field "seat" is gotten to like $lines[2]->{'seat'}; the order of the @lines array tells you which line it is, inside it ar +e anonymous hashes that have the key value pairs to what was found in +side. You're going to probably run into some undef problems, because of the +commas. you can ouput the scv diff ways, I would maybe output it with + forced quote chars, even if empty. Then all your values have the quo +te chars inside, which you could remove later. This whole thing would be paintful, but fun. =cut for (@lines){ my @vals = split(/,/,$_); my $line = {}; my $x=0; for (@vals){ $line->{$fieldname[$x]} = $_; $x++; } push @lines, $line; }

If you are doing this and you actually need it to work for some reason: especially over and over.. Then you have got to use the provided tools, csv modules on cpan.

If they are not installed...
Do you have root access to this box?
Run # cpan
then # install The::Module::Name
should be all good.

The other thing you can do , depending on the module , is download then source , put it in a place you have write access to, and use a # use lib '/path/to/my/modules' line in your script.

The other thing is, as the host/sysadmin for the modules you want. Most times you get what you want! :) But try hard as you can to use already made modules. Although.. you can learn a lot from trying to do this yourself. For example you can learn respect and awe for your fellow coders when you finally give up and use somethingon CPAN!! :)


In reply to Re: Comma delimited file manipulation -- help required. by leocharre
in thread Comma delimited file manipulation -- help required. by swetashah23

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.