Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Compiling Smart::Comments with "-Wc"

by neversaint (Deacon)
on Nov 27, 2005 at 11:12 UTC ( #512005=perlquestion: print w/replies, xml ) Need Help??
neversaint has asked for the wisdom of the Perl Monks concerning the following question:

Dear Masters,
I have this code - - that contain this line:
use Smart::Comments; ### Begin printing here... print "Just example\n";
Now, when I try to compile this file of mine with this command:
$ perl -Wc
It produce this warning when I do that, and it suddenly replace the current document I'm editing with ""?
Subroutine UNIVERSAL::VERSION redefined at /usr/lib/perl5/5.8.5/i386-l +inux-thread-multi/ line 253. syntax OK
My questions are:
  • When should you use compilation with -Wc -yes I mean "W" and not "w" - or just simple -c ?
  • How can I resolve this problem, is there something wrong with Smart::Comments?

neversaint and everlastingly indebted.......

Replies are listed 'Best First'.
Re: Compiling Smart::Comments with "-Wc"
by jarich (Curate) on Nov 27, 2005 at 12:55 UTC
    Perl is case sensitive. Thus writing:
    perl -Wc
    is not the same as writing:
    perl -wc

    The latter (with the small w) says turn on warnings for your code. The former says turn on warnings even if parts of the code use no warnings or some other construct to turn off warnings.

    Chances are that you don't really want to be using -W almost ever when compiling your code. But you do want to use -w.

    An important thing to know is that that error message has nothing to do with your code. Your current document isn't being replaced. What is happening is the following:

    1. perl parses your code for use lines and similar directives.
    2. perl then finds the code for the module you're using (ie Smart::Comments) then parses and compiles that code. If that code generates any warnings or compilation errors perl tells you about them.
    3. After all of your modules are compiled and loaded perl compiles the rest of your program. If there are any warnings or compilation errors you'll hear about them now.
    4. perl then executes your code.

    The error you're seeing is being generated in step 2. Something in Smart::Comments' dependancies results in UNIVERSAL::VERSION being defined more than once. This may or may not be a bug. If it's done inside an area which explicitly turns warnings off then generally you won't see this warning. Unless you use -W rather than -w.

    Basic summary: do your compile checks with -wc rather than -Wc (this isn't C), because generally module authors usually turn off warnings only when they really mean it.

    Hope this helps

Re: Compiling Smart::Comments with "-Wc"
by john_oshea (Priest) on Nov 27, 2005 at 11:59 UTC

    When should you use compilation with -Wc or just simple -c ?

    My rule of thumb is, 'all the time, unless I have a very good reason not to'. My editor is set to automatically insert

    use strict; use warnings;
    automatically for every new Perl file I create. As you're running 5.8, I'd recommend doing the same - I can't count the number of times that a warning has caught me doing something stupid.

    How can I resolve this problem, is there something wrong with Smart::Comments?

    I've just copied your code and both checked and run it with no errors or warnings, so the problem is likely to be some misconfiguration or corruption with your setup. Unfortunately, I have no concrete idea of where the problem is likely to be. I'd guess that you possibly have a dependency problem with another module (either missing totally, or a version incompatibility). Given the content of the warning, I'd start by looking at your installation of version, as that's one of 5 direct dependencies for Smart::Comments

    Hopefully someone with more clue and/or coffee in them will be along with a better answer soon - good luck

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://512005]
Approved by integral
[LanX]: choroba IIRC these errors are indicated
[1nickt]: Missing title suppresses the submit button, I think.
[1nickt]: Petroza to answer your question, no, no special permission is needed to post a question.
[LanX]: did you spam before? :)
LanX has to go/
[ambrus]: I hope we didn't mess up the spam filter rules again.
[ambrus]: Our spam filter rules disallow links to certain domains, and some suspicious pharses that have appeared in previous spam advertising cheap online whatevers.
[LanX]: some servers were lagging today, so I suppose the root cause
[LanX]: ambrus no recent patches
[Petroza]: no i haven't posted anything before. It was a more or less long question with a specific issue. I did post a title and the links i added where only part of the element i was searching within the code (so no purpose other than the question itself).

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2017-10-17 15:21 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (233 votes). Check out past polls.