Returning to both Windows and Perl after something of an absence.
The XAMPP application stack is a quick way to get a web server, database and scripting languages onto a Windows box (& other platforms as well). I seem to remember that it was one of the very first one-click application server installers back in the mid-2000s.
Anyway, the version of Perl bundled in the current release (1.8.1) is broken from the point of view of adding new modules. There's a complex Google trail to be followed but the upshot is: it awaits fixing. It's perfectly usable as a script interpreter but when you try to add modules from CPAN it's missing required system libraries and tools.
The simplest solution is to install Strawberry Perl, which is a port of the language and it's supporting ecosystem to win32 or 64:
* install xampp
* install strawberry perl
* check your environment variables to ensure that strawberry's perl.exe is in the system path (by default: C:\strawberry\perl\bin - rather than inside C:\xampp somewhere).
* alter the shebang line of any cgi scripts you want to call on xampp's apache server to point at strawberry perl (by default at: C:\strawberry\perl\bin\perl.exe).
So your cgi scripts will still live in the location defined in xampp/apache (default: C:\xampp\cgi-bin) but they will call the strawberry interpreter instead of the bundled one.
This way, your can use the standard CPAN method of adding Perl modules from the command line (perl -MCPAN -e shell) and it will compile and install them into a location where they can be found by strawberry Perl (C:\strawberry\perl\site\lib) - i.e. it's INC path.
Showing posts with label perl data. Show all posts
Showing posts with label perl data. Show all posts
Monday, November 5, 2012
Wednesday, October 24, 2007
sortable directories
Let's say that you have generated directories full of images from some app like Pure Data. This is pretty basic stuff but easy to forget.
Basically - files with names in a format like file001.jpg, file002.jpg...
In PD, simply provide an sprintf-style argument like: "/file/path/frame%03d.jpg" to the 'makefilename' object. Magic.
opendir DIR, $inPath or die "cannot access $inPath\n";
@imageFilenames = sort(grep{$_ ne '.' && $_ ne '..'} readdir DIR);
closedir DIR;
Without the sort function above, the order of filenames in @imageFilenames will be farily random. That's no good if you want to maybe run through a time series of image.
You may want to append the full path to each filename entry:
my ($i, $z) = (0,0);
foreach $z (@imageFilenames) {
$imageFilenames[$i] = join("", ($inPath, $z));
print "$imageFilenames[$i] \n";
$i++;
}
To shuffle this sorted array:
use List::Util 'shuffle'; # requires Perl 5.8 or later
my @shuffledFilenames = shuffle(@imageFilenames);
Or just omit the orginal sorting function perhaps.
Basically - files with names in a format like file001.jpg, file002.jpg...
In PD, simply provide an sprintf-style argument like: "/file/path/frame%03d.jpg" to the 'makefilename' object. Magic.
opendir DIR, $inPath or die "cannot access $inPath\n";
@imageFilenames = sort(grep{$_ ne '.' && $_ ne '..'} readdir DIR);
closedir DIR;
Without the sort function above, the order of filenames in @imageFilenames will be farily random. That's no good if you want to maybe run through a time series of image.
You may want to append the full path to each filename entry:
my ($i, $z) = (0,0);
foreach $z (@imageFilenames) {
$imageFilenames[$i] = join("", ($inPath, $z));
print "$imageFilenames[$i] \n";
$i++;
}
To shuffle this sorted array:
use List::Util 'shuffle'; # requires Perl 5.8 or later
my @shuffledFilenames = shuffle(@imageFilenames);
Or just omit the orginal sorting function perhaps.
Subscribe to:
Posts (Atom)