[sword-devel] Help for perl script
Fr Cyrille
lafricain79 at gmail.com
Sat Jan 3 01:57:14 MST 2015
Hello,
I would like to use a perl script wrote by a friend, I open a post about
it on the French Ubuntu forum :
http://forum.ubuntu-fr.org/viewtopic.php?pid=18895781
But now it's really difficult to find a solution. For this reason I
decided to wrote you.
I would like to change a text like that :
Tobit # (name of the book)
1 # (chapter, est suivi d'un retour à la ligne(\n))
1 Histoire de Tobit, fils de Tobiel, ...
2 Aux jours de Salmanasar, ...
3 Moi, Tobit...
4 Dans ma jeunesse....
...
64...
2 # new chapter with \n
1 ...
2...
To imp text, the outpout text file is empty...
The perl script:
|#!/usr/bin/perl
#ouverture du fichier à modifier
$entree = $ARGV[0];
open(FICLOC, $entree);
if ( $entree =~ /(.*)\.[^\.]+/ ) {
$book_title = $1;
} else {
$book_title = $entree;
}
#ouverture du fichier modifié
$ext = "txt"; #Insere ici l'extension que tu souhaites pour ton fichier
open(FICOUT, ">", "$book_title_out.$ext");
# Par la suite, je suppose que le titre est dans la variable $book_title
while ($line = <FICLOC>){
# Detection de chapitre
if ($line =~ '/^(\d+)\s*$/') {
$n_chapter = $1;
}
## Detection de versets
if ($line =~ '/^(\d+)\s+(.+)$/') {
$n_verse = $1;
$text_verse = $2;
$formatted_text = "\$\$\$book_title$n_chapter:$n_verse\n$text_verse";
# Ecriture de cette ligne dans le fichier texte
print FICOUT "$formatted_text\n";
}
}|
Maybe you have already a script for this job?
Thanks you for your help,
Br Cyrille
--
L'Africain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/sword-devel/attachments/20150103/ea41c8d4/attachment.html>
More information about the sword-devel
mailing list