Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: turn off strict for production code

by blahblahblah (Priest)
on Sep 12, 2005 at 15:48 UTC ( [id://491298]=note: print w/replies, xml ) Need Help??


in reply to Re: turn off strict for production code
in thread turn off strict for production code

Thank you both for the 'if' pragma suggestion.

As for "perl -c" catching all "strict" errors, these files definitely compile, but it doesn't catch problems like the following:

use strict; my $try = $ARGV[0]; if ($try) { my $var = 'joe'; $$var = 'test'; }

Replies are listed 'Best First'.
Re^3: turn off strict for production code
by ikegami (Patriarch) on Sep 12, 2005 at 15:56 UTC

    Of course! I was only thinking of use strict 'vars'. This is one morning where I should have stayed in bed.

    In any case, I'd rather find this error definitely, rather than have the program fail in wierd and unpredicatable ways. It's a question of whether you want to create no data (by dying from strict) or create bad data (by referencing variables that don't exist). I'd vote for no data over bad data any day of the week.

      In any case, I'd rather find this error definitely, rather than have the program fail in weird and unpredictable ways.
      Using symbolic references is bad form, but it doesn't necessarily mean there's a bug to be found.

        That's true in the general case, but in blahblahblah's case, he specifically called them errors. I was providing help to blahblahblah, not making a general comment.

        In general, it's probably a good idea to explicitely state no strict 'refs' when using symbolic references. no strict 'refs' could be applied to the whole file, but if possible, it should be localized. For example:

        my $ref = do { no strict 'refs'; \*{$sym} };

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://491298]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-19 14:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found