<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<br>
On 04/11/2011 02:11 PM, David Haslam wrote:
<blockquote cite="mid:1302545494450-3442709.post@n4.nabble.com"
type="cite">
<pre wrap="">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").
</pre>
</blockquote>
<snip><br>
<blockquote cite="mid:1302545494450-3442709.post@n4.nabble.com"
type="cite">
<pre wrap="">
Is that not something that a good Perl programmer can add fairly simply?
</pre>
</blockquote>
<br>
The request is that the file globbing be done within the program
rather than at the command line. Or to allow for both.<br>
<br>
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.<br>
<br>
This would be something like:<br>
(from: <a class="moz-txt-link-freetext" href="http://www.perlmonks.org/?node_id=781801">http://www.perlmonks.org/?node_id=781801</a> )<br>
<pre class="code"><div class="codeblock"><pre class="code"><div class="codeblock"><tt class="codetext"><font size="-1"># 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 );
}
}
</font></tt></div></pre><tt class="codetext"><font size="-1"># 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<span class="line-breaker"></span>";
}
}
}
</font></tt></div></pre>
Alternatively, one could modify the program to take a directory
argument instead of a file list.<br>
So if the argument is a directory it would look for all sfm files in
there.<br>
if (-d $ARGV[i]) {<br>
$dir = $ARGV[i];<br>
<pre><code> @files = <$dir/*.sfm>;
</code><code> foreach $file (@files) {
print $file . "\n";
}
}
</code></pre>
<br>
It might be reasonable to take a look at argv and do the following:<br>
if ($ARGV[$i] ~= m/\*/) {<br>
@files = <$ARGV[$i]>;<br>
}<br>
<br>
Hopefully this is helpful to one that has time to actually work on
it.<br>
<br>
In a Un*x environment one can test this last approaches by putting
single quotes around the argument as in:<br>
prog.pl 'Bibles/*.sfm'<br>
<br>
<br>
In Him,<br>
DM<br>
<br>
</body>
</html>