Hello,

This morning I tried to write
a perl script for your problem.

For the moment I wrote the following code.
#!/usr/bin/perl
use warnings;
undef $/;
our $y = 0;
our $number = 1;
our $file = "/Users/michel/Desktop/dominique.txt";
our $result = "/Users/michel/Desktop/myresult";
open (GH, "< $file") or die "cant'open file:$!";
while (our $pet = (<GH>)) {
while ($pet =~ m/./smg) {
$count++;
}
our $lenght = 4096;
for (my $i =1; $i <= int($count/$lenght); $i++) {

our $rep = substr($pet,$y,$lenght);

open (HG, "> $result.$number.txt") or die "cant'create file:$!";
select (HG);
print $rep;
$number += 1;
$y += 4096;
close (HG) or die "can't write:$!";
}
}
close (GH) or die "can't read:$!";
_END_
This script works but there are still 2 problems.

First this script doesn't go to the last newline.
Second the last remainder of the 4096 character chunk
is not printed supposing he is less than 4096 characters.
Also be careful you initial file must be bigger than
4096 character.

I don't have so much time today but perhaps a Perl
scripter here could correct my code.

Best regards,
--
Michael Havlicek
Le Sep 22, 2007, à 7:42 PM, Marconi a écrit :

I have an alphabetical list (21K and growing) with 1200 lines in it. I thought I'd carry it on my iPod in the Notes directory so I could consult it while away from home (instead of buying a PDA to carry the info).

I put the file into the Notes directory on iPod but found, when I went to read it, that it was truncated in the middle of a line somewhere in the Cs. It would appear that iPod notes are limited to maybe 4096 characters max.

I'd like to have a script which would break the front BBEdit document up into smaller than 4096 bytes each files: mylist1.txt, mylist2.txt ... mylist[n].txt.

When run, the script would count 4096 characters into the file, then back up far enough to encounter a line break, then forward one character to include the line break as the last character of the selection. That way, no entry would be broken over two lines. Write the file as [filename]1.

From that point, repeat the process, counting 4096 characters from the last point written to a file and go back to the last line break. Lather, rinse, repeat until the text file has been broken into a series of files small enough to be read by iPod's Notes function.

It would be nicer still if the parts were named mylist_A-B.txt, mylist_C-... with some hint in the file name as to which entries, alphabetically, were contained therein. Since it's an alphabetical listing, the first character on each line tells us where we are.

Can anyone offer advice on how to do this?

Anyone already done something similar?

AppleScript or Perl or...? What's the best tool for something like this?


-- ----------------------------------------------------------------------- -
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_script.shtml>
List archives: <http://www.listsearch.com/bbeditscripting.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>



--
------------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_script.shtml>
List archives: <http://www.listsearch.com/bbeditscripting.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to