[sword-devel] Using Perl script usfm2osos.pl in Windows?

Peter von Kaehne refdoc at gmx.net
Tue Apr 12 01:07:51 MST 2011


As one of the two current maintainers, I would loath to introduce extra complexity. Like testing for Windows and using modules I do not know and can not test, ever. Particularly as there exist perfectly adequate solutions for Windows users - i.e. installing Cygwin or presumably also mingsys.

I will consider introducing the "-d <directory>"  option. This makes sense.

All in all though I do think that while I want to make USFM import more useful, powerful and feature complete, (I have indroduced a whole bunch of new USFM tags, worked on improving xrefs etc) I struggle with the idea of making it easier for people who resist using a suitable working environment. This is not a dig at you David - you produce quality, all the time. But making it easier at the entry end without having the tail end dealt with adequately (dealing with USFM coding idiosyncrasies, full tag support etc, XML validity) will ultimately lead to poor quality modules. 

Peter

Peter
-------- Original-Nachricht --------
> Datum: Mon, 11 Apr 2011 15:11:29 -0400
> Von: DM Smith <dmsmith at crosswire.org>
> An: sword-devel at crosswire.org
> Betreff: Re: [sword-devel] Using Perl script usfm2osos.pl in Windows?

> 
> 
> On 04/11/2011 02:11 PM, David Haslam wrote:
> > My expectations are simple enough...
> >
> > I'd like to be able to use usfm2osis.pl with Windows filespec wildcards.
> > e.g. *.SFM, as the last command line parameter ("like it says on the
> tin").
> <snip>
> >
> > Is that not something that a good Perl programmer can add fairly simply?
> 
> The request is that the file globbing be done within the program rather 
> than at the command line. Or to allow for both.
> 
> There are various perl modules that allow for this. These probably are 
> not part of every distribution, so the program would need to 
> conditionally include them if the platform is windows and if not there, 
> complain (i.e. tell the user which module to use) and fall back to the 
> current behavior.
> 
> This would be something like:
> (from: http://www.perlmonks.org/?node_id=781801 )
> 
> # This BEGIN block avoids including File::DosGlob::Param for non-windows 
> systems BEGIN { if ( $^O =~ /win/i ) { require File::DosGlob::Param; 
> import File::DosGlob::Param qw( dosglob ); } }
> 
> # convert filename wildcards to actual filenames if ( $^O =~ /win/i ) # 
> only if DOS { if ( exists( $INC{'File/DosGlob/Param.pm'} ) ) # only if 
> loaded { dosglob( "Array_Ref" => \@ARGV, "Remove_Empty_Matches" => 1, 
> "Warn_On_Empty_Matches" => 1 ); } END { if ( ( $^O =~ /win/i ) and not 
> exists( $INC{'File/DosGlob/Param.pm'} ) ) { warn "Consider installing 
> module File::DosGlob::Param...\n"; } } }
> 
> Alternatively, one could modify the program to take a directory argument 
> instead of a file list.
> So if the argument is a directory it would look for all sfm files in
> there.
> if (-d $ARGV[i]) {
>    $dir = $ARGV[i];
> 
> |   @files =<$dir/*.sfm>;
> ||   foreach $file (@files) {
>      print $file . "\n";
>    }
> }
> |
> 
> 
> It might be reasonable to take a look at argv and do the following:
> if ($ARGV[$i] ~= m/\*/) {
> @files = <$ARGV[$i]>;
> }
> 
> Hopefully this is helpful to one that has time to actually work on it.
> 
> In a Un*x environment one can test this last approaches by putting 
> single quotes around the argument as in:
> prog.pl 'Bibles/*.sfm'
> 
> 
> In Him,
>      DM
> 

-- 
NEU: FreePhone - kostenlos mobil telefonieren und surfen!			
Jetzt informieren: http://www.gmx.net/de/go/freephone



More information about the sword-devel mailing list