On Jan 20, 2004, at 9:19 AM, Dan Muey wrote:


Oops left out a sentence....

sorry for the delay.


p0: yes, one can use an import() from a package
to make something like the scam of 'require in line'

Why is it a scam if that's what I want to do for myself?

I presume we are talking about <http://www.nntp.perl.org/group/perl.beginners/58676>

eg:
>      package Foo::Monkey;
>      sub import {
>          for my $pragma (qw(strict warnings)) {
>              require "$pragma.pm";
>              $pragma->import;
>          }
>      }

which does have the technical nit that it did not
end with
        1;

so is not really ready to be rolled up as a perl module.
cf:
<http://www.nntp.perl.org/group/perl.beginners/58551>

rather than starting with a code template of

        #!/usr/bin/perl
        use strict;
        use warnings;

So the idea of learning about how to do an 'import' is
a worthwhile crusade in itself. I'm just not convinced
that it really has the voodoo one would want since it
of course is doing the obligatory two step of first
requiring the pragma and then invoking it's import method...

cf the distinctions between 'require' and 'use'.

So my notion of 'scam' derives from the politer approach
to the comedy of someone coming up with a Way to solve a
problem that seems fundamentally structurally more complex
than the problem that it is trying to solve.

for the twin pragma of 'use strict' and 'use warnings'
{ oye! }

p1: But there is this minor technical overhead that
comes with the process -

        1.a: one needs to use h2xs to make sure that the
                module will conform with the current best practices
                and be appropriately installable in the CPAN way

                my module or strict and warnings?
                One would assume the the developer has a responsibility
                to make their code solid and as compatible and compliant as possible

oh quite right. So why would one want to add in a module that had merely the importing of the two lines that are pragma?????

which is the target of my rant. I of course would not
feel morally upright if I had constructed a perl module
that did not contain

        a. the version of perl that was my minimum to bid
                use 5.006001;
        b. the canonical brace of caution:
                use strict;
                use warnings;
        c. the version value:
                our $VERSION = '1.3';

The reason that I of course appeal to the h2xs approach is
that it will include the base suite of files

        a. MANIFEST
        b. Makefile.PL
        c. foo.pm
        d. t/1.t

So that I can have a basic framework for making sure that
I can get the core steps done
        perl *.PL
        make
        make test
        make install

So now the problem has evolved from merely two lines of
pragma, to a minimum of four files that I need to keep
under source code control.....

        1.b: one has to maintain that module just to make the
                two lines of pragma readily available to all of one's
                perl code.
                
                If that's the point of the module and users know that,
                isn't the maintainer supposed to, well er maintain it properly?

                Also wouldn't the script author have to do the same thing
                except in all his scripts instead of one place?

Oh yes... and that of course is where we are now up to the four files in the SCCS du jure, and ....

        1.c: the count of lines of the perl module vice the
                simple inclusion of the two lines makes the process
                a bit Wonky if you know what I mean.

Not really, if we are talking strictly line counts then do this:


in 50 scripts:
use Foo::Monkey; = 50 lines
(
ok 100 if you count:
sub import { for('strict',warnings') { if(gotmodule($_) { $_->import; } } }
# gotmodule is a function in side Foo::Monkey that basically does eval("use $_[0]")
# and returns true if it was able to be loaded, it works too I tested it
# also it avoids killing the script if it can't be loaded since it only does $_->import
# if the module could be use()ed
)
you get strict and warnings plus the many other nifty things about Foo::Monkey


use strict;use warnings = 100 lines.

                So depending on how you look at it, there are less or the same
                amount of *lines* but many more advantages as far as I can tell.


We're missing the part where all perl scripts start with

#!/usr/bin/perl

since we can be pedantic.... 8-)

But of course so far we have not included

        a. the POD for the module
        b. the readme and change files

....

p2: clearly the fact has been established that it can be
done, but it also notes the 'and you want this pain why?' problem....

I don't understand the pain you speak of, could you define more clearly
why I don't want to do the import() to make it automatic so this module's
users have to consciously turn off strict and warnings instead of
consciously turn it on like we tell people to do over an over an over...

Perchance this is the crucial point.


If the coders in your organization are failing to do this,
and one needs to create a perl module to wrap the pragma
for them, perchance there is some other more pressing issue
that really needs to be addressed?

I personally support the use of Flogging Bad Coders.....

I mean as long as I make it clear, and I would definitely blab about it as an advantage, that by doing
use Foo::Monkey;
# enables strict and warnings for your script for better scripting practice!!
# If you don't like that use no warnings and no strict.. But why would you do that?

I don't think I will ever be able to deal with a


Foo::Monkey

in quite the same light ever again....

8-)

I of course start from 'templates' of code stuff, so
that my stock perl code comes out the door for a mere
dull boring illustrative code as:

        #!/usr/bin/perl -w
        use strict;
        
        # #FILENAME# - is for

so yes, technically, now that I do 5.8 I should upgrade that
template...

But IF you find that the solution of Foo::Monkey is simpler
to implement as a corporate policy in lieu of Flogging, I
am all the more willing to support your life style choice here...

ciao
drieux

---


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to