[OS X TeX] OT-latex file management

J. O'Rourke jo at loyolabook.com
Wed Apr 28 15:50:22 EDT 2004


On Apr 27, 2004, at 5:00 PM, TeX on Mac OS X Mailing List wrote:

> OT-latex file management

> Only problem, I would have to maintain a couple hundred problems in
> separate files.

I haven't followed the whole discussion here, but extracting selected 
problems from the file containing the couple hundred problems may be 
workable -- i.e. separate each problem in the big file with

%SomeSeparator

and copy out only the wanted problems from the big file with a filter --

--- snip ---
#!/usr/bin/perl -w

my @selectedProblems = qw/34 89 27 90/ ; # EDIT list of problems to 
select.
#
use strict ;

my %selectedProblems = () ; # copy list to a hash to use exists() below 
(oh the horror of exposing source!)
foreach (@selectedProblems) {
     $selectedProblems{$_} = "" ;
}

my $counter = 0 ;
my $selectedFlag ;

open(PROBLEMS,"<in.tex") ;	#  EDIT
open(SELECTED,">out.tex") ;  # EDIT
while(<PROBLEMS>) {
     if (/SomeSeparator/) { 	# EDIT to match separator in input file
         $counter++ ;
         $selectedFlag = 0 ;
         $selectedFlag = 1 if exists ($selectedProblems{$counter}) ;
     }
     print  SELECTED $_ if ($selectedFlag == 1) ;
}
exit();
--- snip ---

This, uh, could use a few refinements.

Warm regards,
John O'Rourke



Loyola Book Composition -- jo at loyolabook.com
723 Camino Plaza, PMB 207, San Bruno, Calif. 94066-3401
tel (650) 871-2855 -- fax (650) 871-2856


<a href="http://www.loyolabook.com/jo.vcf">vCard</a>


-----------------------------------------------------
Please see <http://www.esm.psu.edu/mac-tex/> for list
guidelines, information, and LaTeX/TeX resources.





More information about the MacOSX-TeX mailing list