Is it correct that strict and warnings will not apply to checking the code in MYCLASS?

Discussion in 'Perl Misc' started by ioneabu@yahoo.com, Jan 6, 2005.

  1. Guest

    if I put

    use strict;
    use warnings;
    use MYCLASS;

    at the top of my program, is it correct that strict and warnings will
    not apply to checking the code in MYCLASS? I did not know about this
    and missed a big error using a global instead of a lexical. When I put
    them in my class/module file, the error was picked up.
    It may sound dumb but maybe worth mentioning.

    wana
     
    , Jan 6, 2005
    #1
    1. Advertising

  2. Paul Lalli Guest

    <> wrote in message
    news:...
    > if I put
    >
    > use strict;
    > use warnings;
    > use MYCLASS;
    >
    > at the top of my program, is it correct that strict and warnings will
    > not apply to checking the code in MYCLASS? I did not know about this
    > and missed a big error using a global instead of a lexical. When I

    put
    > them in my class/module file, the error was picked up.
    > It may sound dumb but maybe worth mentioning.


    strict and warnings are lexically scoped, and for good reason. Imagine
    a module author who's code 'works' but is not strict-compliant, and/or
    generates warnings. It would be very bad for the user of such a module
    to be able to break the module simply by using strict and/or warnings in
    his own code. Worse would be if the user of such a module was *unable*
    to use the module without disabling strict and warnings in his own code.

    When creating a module, you should put
    use strict;
    use warnings;
    near the top of the .pm file (right under the package declaration).

    See also:
    perldoc warnings
    for some features that are helpful to module authors.

    Paul Lalli
     
    Paul Lalli, Jan 6, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mario Fratelli
    Replies:
    32
    Views:
    1,456
    Phlip
    Dec 9, 2003
  2. Dave
    Replies:
    1
    Views:
    367
    Ron Natalie
    Dec 8, 2003
  3. modemer
    Replies:
    11
    Views:
    658
    modemer
    Mar 21, 2005
  4. Gunnar G
    Replies:
    5
    Views:
    393
    Howard
    Jul 8, 2005
  5. tom
    Replies:
    5
    Views:
    429
Loading...

Share This Page