Adding Perl modules?
MacFH - C E Macfarlane - News
news at macfh.co.uk
Tue Dec 7 04:41:51 PST 2021
On 07/12/2021 06:39, David Taylor wrote:
>
> I would like to add the Win32::API to the Perl which comes with
> get_iplayer.
> Is that possible?
Surely, on a Windows machine, all the necessary Win32::* should be
installed already? What does the following command sequence give for
you, my output is as below:
>cpan
cpan> m Win32::API
Module id = Win32::API
CPAN_USERID BULKDD (Daniel Dragan <bulkdd at cpan.org>)
CPAN_VERSION 0.84
CPAN_FILE B/BU/BULKDD/Win32/Win32-API-0.84.tar.gz
MANPAGE Win32::API - Perl Win32 API Import Facility
INST_FILE C:\Programs\Perl\lib\Win32\API.pm
INST_VERSION 0.84
cpan> q
Lockfile removed.
More generally, if you want to see all the modules beginning with
'win32', you can substitute the following for the cpan command:
cpan> m /^win32.*/
> Here is the script I'm trying to run. It analyses two directories for
> their
> total size and returns an output in a format suitable for MRTG. Perhaps I
> should just substitute Win64 for Win32? I've only used Win32 before.
>
> Here's the script in case it clarifies things...
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> # From: http://www.perlmonks.org/?node_id=2311
> # and: https://rt.cpan.org/Public/Bug/Display.html?id=61520
>
> # Note that Windows Vista/Server 2008 or later is required for
> GetTickCount64.
> # This version returns bytes, not MB.
>
> use strict;
> use Win32::API;
> use Sys::Hostname;
>
> my $GetTickCount;
> $GetTickCount = Win32::API->new("kernel32", "int GetTickCount64()");
> my $uptime;
> my $dir1 = '.';
> my $dir2 = '.';
>
> if (@ARGV[0] ne "") {
> $dir1 = @ARGV[0];
> }
>
> if (@ARGV[1] ne "") {
> $dir2 = @ARGV[1];
> }
>
> print &dir_tree_size($dir1) . "\n";
> print &dir_tree_size($dir2) . "\n";
> $uptime = $GetTickCount->Call() / 1000;
> printf "%d day(s) %dh %dm\n", int($uptime/86400),
> int(($uptime/3600)%24),
> int(($uptime%3600)/60);
> print "PC " . hostname . "\n";
> exit 0;
>
> sub dir_tree_size {
> my $dir = shift;
> my ($i,$total, $f);
> $total = 0;
> opendir DIR, $dir;
> my @files = grep !/^\.\.?$/, readdir DIR;
> for $i (@files) {
> $f = "$dir/$i";
> if(-d $f) {
> $total += dir_tree_size($f) }
> else {
> $total += -s $f}
> }
> return $total;
> }
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Although I've written one quite complicated script in Perl, to call
GetIPlayer as it happens, I don't program in it often enough to class
myself as expert enough to help with the above, but perhaps this helps,
it shells out to DOS:
https://bytes.com/topic/perl/answers/852485-directory-size-windows-activeperl
More information about the get_iplayer
mailing list