Ask a Question related to PERL Beginners, Design and Development.
-
Drieux #1
On import v. Just Do It.
p0: yes, one can use an import() from a package
to make something like the scam of 'require in line'
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
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.
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.
p2: clearly the fact has been established that it can be done,
but it also notes the 'and you want this pain why?' problem....
ciao
drieux
---
Drieux Guest
-
@import CSS
Having recently redeveloped our http://www.newmediaboutique.com site using XHTML Strict and CSS, I've noticed a number of other sites using the... -
SWF import ID3.1
hello, I've just read that if you wanted to use SWF in ID.31 you have to convert it to Quicktime. When I place QT-movie into ID why does the... -
hoq to import a gif
hi, i need to import a transparent gif into a freehand document, but the background of the gif looks black, somebody can help me please i need it... -
CSV import
When using something like this: LOAD DATA LOCAL INFILE '/tmp/phpKBjUWb' INTO TABLE `indoma` FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' ... -
import psd into psd
is there anyway to import an existing psd file into a second psd file so that the layers, masks, etc. remain intact? in the new file, i simply want... -
Dan Muey #2
RE: On import v. Just Do It.
> p0: yes, one can use an import() from a package
Why is it a scam if that's what I want to do for myself?> to make something like the scam of 'require in line'
my module or strict and warnings?> 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
>
One would assume the the developer has a responsibility
to make their code
If that's the point of the module and users know that,> 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.
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?
Not really, if we are talkking strictly line counts then do this:>
> 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.
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 thae 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.
I don't understand the pain you speak of, could you define more clearly>
> p2: clearly the fact has been established that it can be
> done, but it also notes the 'and you want this pain why?' problem....
>
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...
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 warnigns and no strict.. But why would you do that?
Thanks
Dan
<http://learn.perl.org/> <http://learn.perl.org/first-response>> ciao
> drieux
>
> ---
>
>
> --
> To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
> For additional commands, e-mail: [email]beginners-help@perl.org[/email]
Dan Muey Guest
-
Dan Muey #3
Re: On import v. Just Do It.
Oops left out a sentence....
Why is it a scam if that's what I want to do for myself?> p0: yes, one can use an import() from a package
> to make something like the scam of 'require in line'
my module or strict and warnings?> 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
>
One would assume the the developer has a responsibility
to make their code solid and as compatible and compliant as possible
If that's the point of the module and users know that,> 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.
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?
Not really, if we are talking strictly line counts then do this:>
> 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.
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.
I don't understand the pain you speak of, could you define more clearly>
> p2: clearly the fact has been established that it can be
> done, but it also notes the 'and you want this pain why?' problem....
>
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...
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?
Thanks
Dan
> ciao
> drieuxDan Muey Guest
-
Drieux #4
Re: On import v. Just Do It.
On Jan 20, 2004, at 9:19 AM, Dan Muey wrote:
sorry for the delay.> Oops left out a sentence....
I presume we are talking about>>> 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?
<http://www.nntp.perl.org/group/perl.beginners/58676>
eg:which does have the technical nit that it did not> package Foo::Monkey;
> sub import {
> for my $pragma (qw(strict warnings)) {
> require "$pragma.pm";
> $pragma->import;
> }
> }
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.
oh quite right. So why would one want to add in a> my module or strict and warnings?>> 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
>>
> One would assume the the developer has a responsibility
> to make their code solid and as compatible and compliant as possible
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.....
Oh yes... and that of course is where we are now up to>>> 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?
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
.....
Perchance this is the crucial point.>>> 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...
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 don't think I will ever be able to deal with a> 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?
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
---
Drieux Guest
-
Dan Muey #5
RE: On import v. Just Do It.
> On Jan 20, 2004, at 9:19 AM, Dan Muey wrote:
Yes>>> > 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>
You forgot c.1:>
> 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.
>> compliant as possible> > my module or strict and warnings?> >> 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
> >>
> > One would assume the the developer has a responsibility
> > to make their code solid and as compatible and
>
> 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';
sub VERSION { return $VERSION; }
of course sub VERSION could lead to anarchy :)
and as you mentioned above:
d. 1; at the end
The target of my rant of your rant is that this is only one
little part of Foo::Monkey (actual module names have been changed
to protect the innocent), rarely does anyone need ot post the
entire code when trying to figure out a single simple solution to one issue.
And if that becomes necessary then the thread will request that eventually.
Except that you are assumming the module sole purpose is to do use strict and warnings for you.>
> 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.....
>
And the OP wasn't asking abou the proper way to build a module.
Which have nothgin to do with the price of tea in China at this point right?> maintain it properly?> >> >> 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> same thing> >
> > Also wouldn't the script author have to do the>> > 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 ....
>> counts then do this:> >> >> 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> for('strict',warnings') { if(gotmodule($_) {> >
> > in 50 scripts:
> > use Foo::Monkey; = 50 lines
> > (
> > ok 100 if you count:
> > sub import {> function in side Foo::Monkey that basically does> > $_->import; } } }
> > # gotmodule is a> it was able to be loaded, it works too I> > eval("use $_[0]")
> > # and returns true if> killing the script if it can't be loaded since> > tested it
> > # also it avoids> plus the many other nifty things about> > it only does $_->import
> > # if the module could be use()ed
> > )
> > you get strict and warnings> less or the same> > Foo::Monkey
> >
> > use strict;use warnings = 100 lines.
> >
> > So depending on how you look at it, there are> far as I can tell.> > amount of *lines* but many more advantages as
>
>
> 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
>
> ....
>> done, but it> >> p2: clearly the fact has been established that it can be> warnings> >> >> 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>> > 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.....
>> better scripting> > 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> strict.. But why> > practice!!
> > # If you don't like that use no warnings and no>> > 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....
Me neither.
>
> 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
So yes doing a module to do use strict and use warnigns
for you and that's all it does would be overkill.
But if said module had a specific development purpose, stated in
it's documentation (every part of it set up by Proper module creation
process of course), containes all the standard and proper module
goodies (from use 5.6.1; all the way down to 1;), and you want
the development environment created by this module to include as
many good practive features and solidnesses (I like my new word ;p)
as you can (IE use strict and use warnings autmatically if you'll be
developing with this module) then why not pop that in there? It's only
one extra line in my version in a module that is a few hundred or so
long. And it can always be turned off, but it will take effort to
*become* "unsafe" instead of effort to become safe.
[deep gasp for long needed breath and..]
Thanks
Dmuey
Dan Muey Guest



Reply With Quote

