Anki-Import

 view release on metacpan or  search on metacpan

lib/Anki/Import.pm  view on Meta::CPAN

  };
  open (my $handle, "<:encoding(UTF-8)", $path) or logf("Could not open $path");;
  chomp(@lines = <$handle>);
  close $handle;
  logi('Source file loaded.');

  # pad data with a blank line to make it easier to process
  push @lines, '';

  # do the stuff we came here for
  validate_src_file(); logd(\@notes);
  generate_importable_files($pd);

  # print a success message
  unless ($args->{'quiet'}) {
    set_log_level('info');
    logi("Success! Your import files are in the $pd"
      . '/anki_import_files directory');
  }

  # fin
}

# functions for first pass parsing of source data
sub validate_src_file {
  logi('Validating source file');

  # throw error if file is empty
  logf('Source data file is empty.') if !$lines[0];

  # outer loop for parsing notes
  my %fields;  # keeps track of number of fields for each type of note
  while (next_line()) {

    # ignore blank lines



( run in 0.505 second using v1.01-cache-2.11-cpan-a5abf4f5562 )