[26296] in Perl-Users-Digest
Perl-Users Digest, Issue: 8476 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 1 21:05:25 2005
Date: Sat, 1 Oct 2005 18:05:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 1 Oct 2005 Volume: 10 Number: 8476
Today's topics:
ANNOUNCE: ExtUtils-ModuleMaker-0.43 and ExtUtils-Modul <jkeen_via_google@yahoo.com>
Need help with pack <nomail@inval.id>
Re: Need help with pack <someone@example.com>
Re: Need help with pack <msg_me@pm.org>
Re: Need help with pack <1usa@llenroc.ude.invalid>
Re: Need help with pack (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 1 Oct 2005 15:51:15 GMT
From: James E Keenan <jkeen_via_google@yahoo.com>
Subject: ANNOUNCE: ExtUtils-ModuleMaker-0.43 and ExtUtils-ModuleMaker-PBP-0.08
Message-Id: <Inp8wE.1IHF@zorch.sf-bay.org>
ANNOUNCE
ExtUtils::ModuleMaker version 0.43 is now available on CPAN
(<http://search.cpan.org/dist/ExtUtils-ModuleMaker/>).
ExtUtils::ModuleMaker is a replacement for the most typical use of
the h2xs utility bundled with all Perl distributions: the creation
of the directories and files required for a pure-Perl module to be
installable with make and distributable on CPAN.
A companion distribution, ExtUtils::ModuleMaker::PBP, version 0.08,
is also now available and is described below.
DESCRIPTION
ExtUtils::ModuleMaker was created by R Geoffrey Avery in 2001. I
took over maintenance of the distribution in July 2005. The central
focus of ExtUtils::ModuleMaker remains unchanged, as do its
modalities. The recommended way to get started with
ExtUtils::ModuleMaker is the modulemaker command-line utility which
prompts the user to enter a module name and other information and
then creates the directories and files needed to bring that module
to life. modulemaker is extremely easy for novice module authors to
use and, as such, typifies the Perl virtue of laziness. The user can
also provide modulemaker with command-line arguments.
ExtUtils::ModuleMaker can also be called from within a Perl program
via its "new()" and "complete_build()" methods.
In the past three months, however, there have been significant
enhancements to ExtUtils::ModuleMaker's functionality as well as
improvements to the distribution itself.
New Options
Fourteen new attributes have been added to ExtUtils::ModuleMaker's
default values. Five of these provide the user with more
fine-grained control over the directories and files created by
running ExtUtils::ModuleMaker:
INCLUDE_SCRIPTS_DIRECTORY
INCLUDE_MANIFEST_SKIP
INCLUDE_TODO
INCLUDE_LICENSE
INCLUDE_FILE_IN_PM
Eight of the new default values provide the user with greater
control over which test files to include, how to name them and how
many modules each test file tests:
FIRST_TEST_NUMBER
TEST_NUMBER_FORMAT
TEST_NAME
EXTRA_MODULES_SINGLE_TEST_FILE
TEST_NAME_DERIVED_FROM_MODULE_NAME
TEST_NAME_SEPARATOR
INCLUDE_POD_COVERAGE_TEST
INCLUDE_POD_TEST
Finally, a new default value is provided to enable the user to save
selections made via modulemaker as new default values:
SAVE_AS_DEFAULTS
By enabling the user to save his/her selections as new default
values, the latest version of ExtUtils::ModuleMaker significantly
enhances the user's ability to customize its use.
But wait, there's more!
Improved Subclassability
While ExtUtils::ModuleMaker always was subclassable, its
subclassability is now easier and better documented.
ExtUtils::ModuleMaker's default values and private methods, formerly
found entirely in 'lib/ExtUtils/ModuleMaker.pm', have been moved
into three separate packages based on functionality:
lib/ExtUtils/ModuleMaker/Defaults.pm
lib/ExtUtils/ModuleMaker/Initializers.pm
lib/ExtUtils/ModuleMaker/StandardText.pm
Private methods called within "ExtUtils::ModuleMaker::new()" are
found in Initializers.pm. Private methods within
"ExtUtils::ModuleMaker::complete_build()" are found within
StandardText.pm. A potential subclasser's attention is therefore
more precisely focused on the methods needing overriding.
ExtUtils::ModuleMaker::PBP
As an illustration of how to subclass ExtUtils::ModuleMaker, I have
written a companion Perl extension, ExtUtils::ModuleMaker::PBP, also
now available on CPAN, which you can use to create the skeleton for
a Perl extension in the manner recommended by Damian Conway in his
recent book *Perl Best Practices* (O'Reilly, 2005)
<http://www.oreilly.com/catalog/perlbp/>. ExtUtils::ModuleMaker::PBP
includes its own command-line utility, mmkrpbp, which works in the
same way as modulemaker.
The net effect of these enhancements is to create a comfortable
learning curve for the ExtUtils::ModuleMaker user.
* A beginner can create the framework for a Perl distribution by
typing modulemaker at the command-prompt and then filling in a
few blanks.
* An advanced beginner can provide command-line arguments to
reduce the amount of editing of files needed once the
distribution has been created.
* An intermediate user can save his/her modulemaker selections as
new default values, thereby saving keystrokes in the creation of
future distributions.
* An advanced intermediate user can achieve finer control over the
directories and files created by using ExtUtils::ModuleMaker
within a Perl program and calling appropriate methods.
* Finally, an advanced user can subclass ExtUtils::ModuleMaker to
create templates for other distributions.
But wait, there's still more!
Structural Improvements
As a CPAN distribution ExtUtils::ModuleMaker has been significantly
improved with the addition of new tests and documentation. As
measured by Devel::Cover, ExtUtils::ModuleMaker's test coverage is
now very high. Only the modulemaker utility's interactive mode lacks
good coverage.
In particular, the test suite tests to see whether a file containing
new default values can be saved in an appropriate location on the
user's system and whether such a file, when used, generates values
expected to override ExtUtils::ModuleMaker's own default values. In
the event that a user is upgrading from one version of
ExtUtils::ModuleMaker to another, the test suite also makes certain
to leave intact and file of default values the user has already
saved on disk so that it is still intact after the upgrade.
During the testing process, new directories and files are now
created in temporary directories which are created and then erased
via File::Temp.
ExtUtils::ModuleMaker itself is intended to be backwardly compatible
with Perl 5.5, but most of its test suite requires Perl 5.6. The
tests which require 5.6 are all wrapped in SKIP blocks, so 5.5 users
should be able to test and install the distribution with no problem.
ACKNOWLEDGEMENTS
Acknowlegements go out to:
* Geoff Avery for creating and popularizing ExtUtils::ModuleMaker
-- and for willing to put his child up for my adoption!
* David Golden for suggestions for enhancements in functionality
and for helping to make the 'learning curve' concept more
explicit.
* Damian Conway for permission to lift sections of his code from
Module::Starter::PBP.
* The following beta testers, CPAN testers, Perl hackers and
Perlmonks, each of whom made suggestions at one or more stages
in the development process (see ACKNOWLEDGEMENTS in
documentation for details):
Brian Clarkson
Scott Godin
imacat
Reinhard Urban
Michael G Schwern
A Sinan Unur
Paul Lalli
davidrw
tlm
Anonymous Guest
CountZero
xdg
Tanktalus
holli
TheDamian
nothingmuch
Alex Gill
Marc Prewitt
chromatic
dave_the_m
randyk
njh
SUPPORT
Please report any bugs or feature requests to
"bug-ExtUtils-ModuleMaker@rt.cpan.org", or through the web interface
at <http://rt.cpan.org>.
------------------------------
Date: Sat, 1 Oct 2005 23:00:01 +0000 (UTC)
From: kj <nomail@inval.id>
Subject: Need help with pack
Message-Id: <dhn4dh$bqd$1@reader1.panix.com>
I want to write the function to_bits that takes a floating point
number as argument and returns an array of 32 ones or zeroes,
corresponding to the bits of the input argument.
I have been staring at the docs for pack and unpack for a while
now trying to figure out how to use them to do this and I am as
clueless about it as I was when I first started. Also, perlpacktut
was no help either [1].
If someone could please tell me how to generate an array of one's
and zeros corresponding to the bits in a floating point number I'd
be very grateful.
kj
[1] Lest I appear very lazy or very stupid, I should point out that
I generally have *no problem* understanding the documentation for
Perl built-in functions. pack is a very exceptional case. It is
the only Perl function that I consider mysterious in the least.
I wish I could convey my bewilderment upon reading the docs for
pack. From the very first sentences it is as if I were reading
some English-like code in which all words mean something different
from what I think they should mean. As I said, the tutorial is no
help, because ultimately the tutorial just gives cookbook recipes
which I can follow, but I have no idea what I'm doing. If what I
need to do is not described in one of the recipes, then *I have no
idea* of how to devise my own recipe.
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
------------------------------
Date: Sat, 01 Oct 2005 23:26:15 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Need help with pack
Message-Id: <rWE%e.321804$on1.298076@clgrps13>
kj wrote:
> I want to write the function to_bits that takes a floating point
> number as argument and returns an array of 32 ones or zeroes,
> corresponding to the bits of the input argument.
>
> I have been staring at the docs for pack and unpack for a while
> now trying to figure out how to use them to do this and I am as
> clueless about it as I was when I first started. Also, perlpacktut
> was no help either [1].
>
> If someone could please tell me how to generate an array of one's
> and zeros corresponding to the bits in a floating point number I'd
> be very grateful.
$ perl -le' print for unpack q/a/ x 32, unpack q/b*/, pack q/f/, 5.678 '
1
0
1
1
0
1
0
0
0
1
0
0
1
1
0
1
1
0
1
0
1
1
0
1
0
0
0
0
0
0
1
0
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sat, 1 Oct 2005 23:29:11 +0000 (UTC)
From: tlm <msg_me@pm.org>
Subject: Re: Need help with pack
Message-Id: <dhn647$f51$2@reader1.panix.com>
>I want to write the function to_bits that takes a floating point
>number as argument and returns an array of 32 ones or zeroes,
>corresponding to the bits of the input argument.
How about this (untested):
sub to_bits {
my $f = pack 'f', shift;
return reverse map vec( $f, $_, 1 ), 0 .. 31;
}
HTH,
tlm
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
------------------------------
Date: Sat, 01 Oct 2005 23:36:48 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Need help with pack
Message-Id: <Xns96E2C7853F68Dasu1cornelledu@127.0.0.1>
kj <nomail@inval.id> wrote in news:dhn4dh$bqd$1@reader1.panix.com:
> I want to write the function to_bits that takes a floating point
> number as argument and returns an array of 32 ones or zeroes,
> corresponding to the bits of the input argument.
>
> I have been staring at the docs for pack and unpack for a while
> now trying to figure out how to use them to do this and I am as
> clueless about it as I was when I first started. Also, perlpacktut
> was no help either [1].
>
> If someone could please tell me how to generate an array of one's
> and zeros corresponding to the bits in a floating point number I'd
> be very grateful.
#!/usr/bin/perl
use strict;
use warnings;
print unpack 'b*', pack 'f', 3.45;
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: 2 Oct 2005 00:01:19 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Need help with pack
Message-Id: <dhn80f$4vn$1@mamenchi.zrz.TU-Berlin.DE>
kj <nomail@inval.id> wrote in comp.lang.perl.misc:
>
>
>
> I want to write the function to_bits that takes a floating point
> number as argument and returns an array of 32 ones or zeroes,
> corresponding to the bits of the input argument.
>
> I have been staring at the docs for pack and unpack for a while
> now trying to figure out how to use them to do this and I am as
> clueless about it as I was when I first started. Also, perlpacktut
> was no help either [1].
>
> If someone could please tell me how to generate an array of one's
> and zeros corresponding to the bits in a floating point number I'd
> be very grateful.
I'll show how to generate a string (not an array) of zeroes and ones.
You need two steps. First use the "f" template (single-precision float)
to get the four bytes that make up a 32-bit float into a string. If
the number is in $_:
my $str = pack 'f', $_;
Next, unpack the result as a bit string, using the "b" template
my $bits = unpack 'b32', $str;
Run it for a few examples
printf "%.3f -> %s\n", $_, unpack 'b32', pack 'f', $_ for
1/8, 1/4, 1/2, 1, 2, 4, 8;
and see if you can make heads or tails of the output. The bytes may not
be in the expected order. On my machine, I get:
0.125 -> 01111100000000000000000000000000
0.250 -> 01111100000000010000000000000000
0.500 -> 11111100000000000000000000000000
1.000 -> 11111100000000010000000000000000
2.000 -> 00000010000000000000000000000000
4.000 -> 00000010000000010000000000000000
8.000 -> 10000010000000000000000000000000
If you want an array, either split the result in single characters, or
use
map vec( $str, $_, 1), 0 .. 31
instead of unpacking with "b".
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 8476
***************************************