Help for this page

Select Code to Download


  1. or download this
      use Text::CSV_XS qw( csv );
      my $aoa = csv (in => "file.csv");
    
  2. or download this
      my $aoa = csv (in => "file.csv", sep_char => ";");
    
  3. or download this
      my $aoa = csv (in => "file.csv", sep => ";");
    
  4. or download this
      use autodie;
      use Text::CSV_XS;
    ...
          # do something with the row
          }
      close $fh;
    
  5. or download this
      # Default: return a list of lists (rows)
      my $aoa = csv (in => "file.csv");
    
      # Using the header line: return a list of hashes (records)
      my $aoh = csv (in => "file.csv", headers => "auto");
    
  6. or download this
      open my $fh, "<", "file.csv";
      my @hdr = @{$csv->getline ($fh)};
      $csv->column_names (@hdr);
      while (my $row = $csv->getline_hr ($fh)) {
          ...
    
  7. or download this
      open my $fh, "<", "file.csv";
      my @hdr = @{$csv->getline ($fh)};
      $csv->column_names (@hdr);
      while (my $row = $csv->getline_hr ($fh)) {
    
  8. or download this
      open my $fh, "<", "file.csv";
      my @hdr = $csv->header ($fh);
      $csv->column_names (@hdr);
      while (my $row = $csv->getline_hr ($fh)) {
    
  9. or download this
    sub Text::CSV_XS::header {
        my ($csv, $fh, $seps) = @_;
    ...
        close $h;
        @{$row // []};
        } # Text::CSV_XS::header
    
  10. or download this
    =head2 $csv->header ($fh)
    
    ...
     while (my $row = $csv->getline ($fh)) {
         ...
         }
    
  11. or download this
    
      #---
    ...
      $csv->column_names ($csv->header ($fh, [ ";", ",", "|" ]));
      while (my $row = $csv->getline_hr ($fh)) {
          # $row = { foo => "1", bar => "baz" }