Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- # makenotes.pl A text splitting tool for iPod Notes
- # (C) 2008 Matthijs Dalhuijsen (GPL)
- local $|=1;
- unless (@ARGV) {
- print "makenotes -- formats text documents for usage on iPod\n";
- print "Usage: $0 <filename(s)>\n";
- exit(1);
- }
- foreach my $file (@ARGV) {
- if (-f $file) {
- print "$file exists\n";
- &chopfile($file);
- } else {
- print "$file not found\n";
- }
- }
- sub chopfile {
- my $f = shift;
- open(F,$f);
- my @txt = split(//,join("",<F>));
- print "processing $f\n";
- print "Please give a title for this book\n> ";
- my $title = <STDIN>;
- chomp($title);
- print "creating dir and splitting file into subfiles in 3 seconds\n";
- sleep(1);
- print "2\n";
- sleep(1);
- print "1\n";
- sleep(1);
- mkdir($title);
- chdir($title);
- my $i = 0;
- open(IF,">".$title."_".$i.".txt");
- for (my $x = 0; $x < @txt; $x++) {
- print IF $txt[$x];
- if ($x % 3800 == 0) {
- print IF "<TITLE>$i $title</TITLE>";
- print IF "<a href=\"".$title."_".($i-1).".txt\">prev (".($i-1).")</a> ";
- print IF "<a href=\"".$title."_".($i+1).".txt\">prev (".($i+1).")</a> ";
- print IF "<br><br>";
- $i++;
- open(IF,">".$title."_".$i.".txt");
- print $title."_".$i."\n";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement