Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I'm sure Tie::CSV_file is a fine module, but you might also give Parse::CSV a spin. Here's some cutting and pasting of some code I wrote recently.

use Parse::CSV; # Define the names of our csv fields # my $csv_fields = [ 'CoordinatorID', 'CompanyName', 'FirstName', 'LastName', 'City', 'State', 'csgaccount', 'Username', 'DomainName' ]; # Populate these hashrefs with data for comparison with the # list of names. # my $provisioned = fetch_csv_accounts({ filename => $opts->{prov}, fields => $csv_fields }); # {{{ sub fetch_csv_accounts # sub fetch_csv_accounts { my $args = shift; die "No field names provided...\n" unless defined $args->{fields}; die "No filename provided...\n" unless defined $args->{filename +}; # Default the keyfield to Username if nothing # is passed to this sub. # my $keyfield = $args->{keyfield} ? $args->{keyfield} : 'Username'; # # Create a Parse::CSV object for easy csv iteration # my $prov_csv = Parse::CSV->new( file => $args->{filename}, fields => $args->{fields}, ); die "Error: " . $prov_csv->errstr . "\n" if $prov_csv->errstr; # Loop through each row of the csv file and populate the # hashref. The resulting hashref will look like: # # Username1 -> CoordinatorID # -> CompanyName # -> FirstName # -> Lastname # -> City # -> State # -> csgaccount # -> Username # -> DomainName # Username2 -> CoordinatorID # -> CompanyName # ... etc ... my $return_hash = {}; while ( my $row = $prov_csv->fetch ) { foreach ( keys %{$row} ) { $return_hash->{ $row->{$keyfield} }->{$_} = $row->{$_}; } } return $return_hash; } # }}}


Therapy is expensive. Popping bubble wrap is cheap. You choose.

In reply to Re: Parse error by naChoZ
in thread Parse error by maurkb

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2021-12-02 23:03 GMT
Find Nodes?
    Voting Booth?
    R or B?

    Results (27 votes). Check out past polls.