Gossamer Forum
Home : General : Perl Programming :

Use Strict, but not strict for a section

Quote Reply
Use Strict, but not strict for a section
Is there a way I can use strict for a cgi, but turn strict off (specifically warnings) for a particular section of the code?


Let's say for example, I have a use statement which calls upon a GT module, and sometimes I am not using this cgi with GT products.

So I want to supress the warnings by requiring the module and doing something before the require statement.

Any ideas?
Quote Reply
Re: [Ian] Use Strict, but not strict for a section In reply to
sure, you can do

no strct 'vars';

etc. see perldoc strict for details

--mark
Quote Reply
Re: [Mark Badolato] Use Strict, but not strict for a section In reply to
No you can't, but you can do:

no strict 'vars';

Cool

Although if it is for warning supression then won't it be:

local ($SIG{__DIE__}, $^W);

?

Last edited by:

Paul: Feb 8, 2003, 4:52 PM
Quote Reply
Re: [Ian] Use Strict, but not strict for a section In reply to
Yep, you can use no strict "..."; inside specific blocks of code if you need to. Chek the docs -> strict. The link doesn't specifically tell you that you can use no strict "whatever"; in blocks of code but I read it in one of my books somewhere.

Regards,
Charlie

[edit]Doh, everyone beat me to it![/edit]

Last edited by:

Chaz: Feb 8, 2003, 4:54 PM
Quote Reply
Re: [Mark Badolato] Use Strict, but not strict for a section In reply to
Hi,

Thanks. But does this apply to subs also? It seems to be only for vars.

Crazy

Edit: Thanks Paul and Chaz also.... perhaps the warning suppression is what I need here.

Finished tv paul?

Last edited by:

Ian: Feb 8, 2003, 4:55 PM
Quote Reply
Re: [Ian] Use Strict, but not strict for a section In reply to
>>
But does this apply to subs also? It seems to be only for vars
<<

For vars, subs and refs use:

no strict;

For individuals use:

no strict 'vars';
no strict 'subs';

etc...

or you can use combinations:

no strict 'vars subs';

If you can explain a little more about what you want to do that may make things clearer.

>>
Finished tv paul?
<<

Yeah :)
Quote Reply
Re: [Paul] Use Strict, but not strict for a section In reply to
Thanks Paul.

Quote:
If you can explain a little more about what you want to do that may make things clearer.

Gordon is actually writting it... I had best check this out first and see if this works.

Smile
Quote Reply
Re: [Ian] Use Strict, but not strict for a section In reply to
I can't help but think of Thomas the Tank Engine when you say Gordon Wink
Quote Reply
Re: [Paul] Use Strict, but not strict for a section In reply to
LOL, Thomas is good!
Quote Reply
Re: [Ian] Use Strict, but not strict for a section In reply to
>> Thanks. But does this apply to subs also? It seems to be only for vars.

Again, look at perldoc strict for more information.
Quote Reply
Re: [Ian] Use Strict, but not strict for a section In reply to
If you don't have Perl on your own system and don't have access to the documentation on the server, see Perldoc.com to look up things like this.
Quote Reply
Re: [wysardry] Use Strict, but not strict for a section In reply to
Thanks.

(All our machines have perl on them).

I think we have this sorted now. :)