Dyrcona

notify.pl: What's wrong with this ?

Jun 24th, 2022 (edited)
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.58 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. use Template;
  7. use Text::CSV;
  8.  
  9. my $tt = Template->new();
  10. my $csv = Text::CSV->new({binary=>1});
  11.  
  12. my $fh = open("<:encoding(utf8)", $ARGV[0]) or die("$ARGV[0]: $!");
  13.  
  14. my $headers = $csv->getline($fh);
  15. # The above line give this error:
  16. # Can't locate object method "getline" via package "1" (perhaps you forgot to load "1"?) at ./notify.pl line 14.
  17. $csv->column_names(@{$headers});
  18.  
  19. while (my $data = $csv->getline_hr($fh)) {
  20.     my $output = $data->{id} . ".eml";
  21.     $tt->process("template.tt2", $data, $output);
  22. }
  23.  
  24. close $fh;
  25.  
Add Comment
Please, Sign In to add comment