Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8030231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:42:00+00:00 2026-06-05T00:42:00+00:00

I am writing a Perl script and using the Class::CSV module. I have an

  • 0

I am writing a Perl script and using the Class::CSV module. I have an array of numbers, 5 elements long

$values[0] - $values[4]

I am trying to add a new line to the CSV file and populate the new line with the values from the array. However I keep receiving this error when I try to run the script:

 Failed to create CSV line from line:
 10252205 
 at /usr/lib/perl5/site_perl/5.8.8/Class/CSV.pm line 257
    Class::CSV::Line::string('Class::CSV::Line=HASH(0x1f2d0f20)') called at /usr/lib/perl5/site_perl/5.8.8/Class/CSV.pm line 435
    Class::CSV::string('Class::CSV=HASH(0x1f2c1c00)') called at catchmailstats.pl line 116

Here is the code for the CSV construction:

# Create csv file from the current data
  my $csv = Class::CSV->new(
  fields  => [qw/Month NotSpam Probable Quarantine Spam Total/],
  );

# Creates the first row (Headers)
$csv->add_line({
  Month   => 'Month',
  NotSpam => 'NotSpam',
  Probable => 'Probable',
  Quarantine => 'Quarantine',
  Spam => 'Spam',
  Total => 'Total'
});

# Creates the second row (values)
$csv->add_line([$values[0], $values[1],$values[2],$values[3],$values[4], $total]);

I have also tried it using the other notation style:

# Creates the second row (values)
$csv->add_line({
  Month   => $values[0],
  NotSpam => $values[1],
  Probable => $values[2],
  Quarantine => $values[3],
  Spam => $values[4],
  Total => $total
});

Neither style has worked. Here is something I have noticed, though. The final variable, $total, is the sum of $values[1] through $values[4]. This variable will work just fine.

So my real question is: why won’t references to elements in my array work, but a summation of elements from the same array, compile without a problem? And how can I get the add_line function to accept my array elements?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T00:42:03+00:00Added an answer on June 5, 2026 at 12:42 am

    I think that in your values list, there’s a HASH REF that needs to be dereferenced.

    Use Data::Dumper in your code :

    use Data::Dumper;
    print Dumper @values;
    

    And POST the output, we will see.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a script using Perl and Net::FTP, which is trying to upload a
I am writing a Perl script (in Windows) that is using File::Find to index
I am writing a script that executes a command remotely via SSH using perl.
Using perl 5.8.8 on windows server I am writing a perl cgi script using
I am writing Perl script. In that I have to read log4j.xml file from
I am writing a Perl script that needs to transfer files between computers using
I am writing a Perl script which needs to perform some validations. I have
I am writing small process monitor script in Perl by reading values from Proc
I am trying to write a Perl script using the utf8 pragma, and I'm
I'm writing a Perl script that generates a Bash script. I'm using open() with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.