Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Eliza

By: a guest on Jul 16th, 2008  |  syntax: Perl  |  size: 1.19 KB  |  views: 296  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/perl
  2. # makenotes.pl A text splitting tool for iPod Notes
  3. # (C) 2008 Matthijs Dalhuijsen (GPL)
  4. local $|=1;
  5. unless (@ARGV) {
  6.  print "makenotes -- formats text documents for usage on iPod\n";
  7.  print "Usage: $0 <filename(s)>\n";
  8.  exit(1);
  9. }
  10. foreach my $file (@ARGV) {
  11.  if (-f $file) {
  12.   print "$file exists\n";
  13.   &chopfile($file);
  14.  } else {
  15.   print "$file not found\n";
  16.  }
  17. }
  18. sub chopfile {
  19.  my $f = shift;
  20.  open(F,$f);
  21.  my @txt = split(//,join("",<F>));
  22.  print "processing $f\n";
  23.  print "Please give a title for this book\n> ";
  24.  my $title = <STDIN>;
  25.  chomp($title);
  26.  print "creating dir and splitting file into subfiles in 3 seconds\n";
  27.  sleep(1);
  28.  print "2\n";
  29.  sleep(1);
  30.  print "1\n";
  31.  sleep(1);
  32.  mkdir($title);
  33.  chdir($title);
  34.  my $i = 0;
  35.  open(IF,">".$title."_".$i.".txt");
  36.  for (my $x = 0; $x < @txt; $x++) {
  37.   print IF $txt[$x];
  38.   if ($x % 3800 == 0) {
  39.    print IF "<TITLE>$i $title</TITLE>";
  40.    print IF "<a href=\"".$title."_".($i-1).".txt\">prev (".($i-1).")</a> ";
  41.    print IF "<a href=\"".$title."_".($i+1).".txt\">prev (".($i+1).")</a> ";
  42.    print IF "<br><br>";
  43.    $i++;
  44.    open(IF,">".$title."_".$i.".txt");
  45.    print $title."_".$i."\n";
  46.   }
  47.  }
  48. }