use strict / nostrict

use strict / nostrict

am 14.07.2011 16:18:55 von sono-io

>> #!/usr/bin/perl
>> use Text::CSV;
>> use DBI;
>> use Data::Dumper;
>=20
> There is no "use strict;" and "use warnings;" at the beginning of the =
file:

I see this quite a bit on this list (and elsewhere) and I think =
it's very good advice, so this morning I got to thinking. If these =
pragmas are as important as they are, why is it that they aren't turned =
on in Perl by default? How about if we make them the default settings =
in 5.16 and then add "use nostrict;" and "use nowarnings;" for when =
someone wants to turn them off? In the grand scheme of things I'm still =
relatively new to all this, but it makes total sense to me. If they =
should be used in most every script, why waste the time and thought of =
always having to remember (or remind others) to add them?

Thoughts?

Marc=

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: use strict / nostrict

am 14.07.2011 16:53:09 von Shawn H Corey

On 11-07-14 10:18 AM, Marc wrote:
> If these pragmas are as important as they are, why is it that they aren't turned on in Perl by default? How about if we make them the default settings in 5.16 and then add "use nostrict;" and "use nowarnings;" for when someone wants to turn them off?

For backward compatibility. Yeah, it makes no sense with 5.16 coming
out but there it is.

BTW,it's:

no strict;
no warnings;

See `perldoc -f no`


--
Just my 0.00000002 million dollars worth,
Shawn

Confusion is the first step of understanding.

Programming is as much about organization and communication
as it is about coding.

The secret to great software: Fail early & often.

Eliminate software piracy: use only FLOSS.

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: use strict / nostrict

am 14.07.2011 18:04:09 von Shlomi Fish

Hi Marc,

On Thu, 14 Jul 2011 07:18:55 -0700
Marc wrote:

> >> #!/usr/bin/perl
> >> use Text::CSV;
> >> use DBI;
> >> use Data::Dumper;
> >=20
> > There is no "use strict;" and "use warnings;" at the beginning of the f=
ile:
>=20
> I see this quite a bit on this list (and elsewhere) and I think it's
> very good advice, so this morning I got to thinking. If these pragmas ar=
e as
> important as they are, why is it that they aren't turned on in Perl by
> default? =20

Because doing so will break old code. perl 4 and below didn't have "use
strict;" and the -w flag (which is the precursor to the now more recommended
"use warnings;") was also introduced a bit later. So if we turn them on by
default, then it will break a lot of code.

> How about if we make them the default settings in 5.16 and then add
> "use nostrict;" and "use nowarnings;" for when someone wants to turn them
> off? =20

Well, if you do "use 5.012;" then strict will be turned on by default:

http://www.effectiveperlprogramming.com/blog/468

Also, there's http://beta.metacpan.org/module/Modern::Perl and doing "use
Moose;" (see http://www.iinteractive.com/moose/ ) will also enable "use
strict;" and "use warnings;".=20

> In the grand scheme of things I'm still relatively new to all this, but
> it makes total sense to me. If they should be used in most every script,=
why
> waste the time and thought of always having to remember (or remind others=
) to
> add them?

Well, a good idea is to configure your editor to add them for you automatic=
ally.

Regards,

Shlomi Fish

--=20
------------------------------------------------------------ -----
Shlomi Fish http://www.shlomifish.org/
List of Portability Libraries - http://shlom.in/port-libs

If God exists and is the egoâ€=90maniacal, sadistic and helpless creatu=
re that is
described in the Old Testament, then weâ€=99re in deep trouble.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: use strict / nostrict

am 14.07.2011 20:21:31 von Paolo Gianrossi

--bcaec548620056e49204a80b9b9e
Content-Type: text/plain; charset=ISO-8859-1

2011/7/14 Shlomi Fish

> Hi Marc,
>
> On Thu, 14 Jul 2011 07:18:55 -0700
> Marc wrote:
>
> > >> #!/usr/bin/perl
> > >> use Text::CSV;
> > >> use DBI;
> > >> use Data::Dumper;
> > >
> > > There is no "use strict;" and "use warnings;" at the beginning of the
> file:
> >
> > I see this quite a bit on this list (and elsewhere) and I think
> it's
> > very good advice, so this morning I got to thinking. If these pragmas
> are as
> > important as they are, why is it that they aren't turned on in Perl by
> > default?
>
> Because doing so will break old code. perl 4 and below didn't have "use
> strict;" and the -w flag (which is the precursor to the now more
> recommended
> "use warnings;") was also introduced a bit later. So if we turn them on by
> default, then it will break a lot of code.
>
> > How about if we make them the default settings in 5.16 and then add
> > "use nostrict;" and "use nowarnings;" for when someone wants to turn them
> > off?
>
> Well, if you do "use 5.012;" then strict will be turned on by default:
>
> http://www.effectiveperlprogramming.com/blog/468
>
> Also, there's http://beta.metacpan.org/module/Modern::Perl and doing "use
> Moose;" (see http://www.iinteractive.com/moose/ ) will also enable "use
> strict;" and "use warnings;".
>
> > In the grand scheme of things I'm still relatively new to all this, but
> > it makes total sense to me. If they should be used in most every script,
> why
> > waste the time and thought of always having to remember (or remind
> others) to
> > add them?
>
> Well, a good idea is to configure your editor to add them for you
> automatically.
>

Or use something along the lines of "use Modern::Perl;" to also switch on
some useful stuff..

Paolo Gianrossi

(An unmatched left parenthesis
creates an unresolved tension
that will stay with you all day
-- xkcd

--bcaec548620056e49204a80b9b9e--