flashcard-tools

Tools for working with LaTeX flashcards
git clone git://lumidify.org/flashcard-tools.git (fast, but not encrypted)
git clone https://lumidify.org/flashcard-tools.git (encrypted, but very slow)
git clone git://4kcetb7mo7hj6grozzybxtotsub5bempzo4lirzc3437amof2c2impyd.onion/flashcard-tools.git (over tor)
Log | Files | Refs | README

addcard.pl (726B)


      1 #!/usr/bin/env perl
      2 
      3 use strict;
      4 use warnings;
      5 
      6 die "Loser.\n" if @ARGV != 2;
      7 
      8 sub gen_filename {
      9 	my ($second_idx, @groups) = @_;
     10 	my $str = join "-", map {sprintf "%02d", $_} @groups;
     11 	return sprintf("flashcards/%s_%02d%s", $str, $second_idx, $ARGV[0]);
     12 }
     13 
     14 my @groups;
     15 push @groups, $1 while $ARGV[1] =~ m/(\d+)\.?/g;
     16 if (@groups) {
     17 	my $second_idx = 0;
     18 	my $filename;
     19 	while (-e ($filename = gen_filename $second_idx, @groups)) {
     20 		$second_idx++;
     21 	}
     22 	open my $fh, ">", $filename or die "Moron.\n";
     23 	print $fh $ARGV[1];
     24 	close $fh;
     25 	open $fh, ">", ".cur_card" or die "Fool.\n";
     26 	print $fh substr($filename, 11);
     27 	close $fh;
     28 	# Change this if you want a different editor
     29 	system("vi", $filename);
     30 } else {
     31 	die "Idiot.\n";
     32 }