Arcane has asked for the wisdom of the Perl Monks concerning the following question:

ok... I added a new module to a program that I am working on. The module was XML::Mini::Document. It also uses the XML::Mini::Element. then i go to run it and i am swamped with warnings. Warnings that were suppressed before, but now they are visible. What should I do??? thanks

Replies are listed 'Best First'.
Re: PERL Warnings
by friedo (Prior) on Nov 21, 2005 at 20:15 UTC
    Looking at the source of XML::Mini::Document, it has the dreaded $^W = 1; right at the top. That turns on warnings globally. It would be best to submit a patch that changes that to use warnings or, at the very least, uses local $^W = 1 instead. To turn the warnings off in your code, you can set local $^W = 0; or no warnings; in the appropriate place.
Re: PERL Warnings
by cbrandtbuffalo (Deacon) on Nov 21, 2005 at 20:18 UTC
    Looking at the source for that module, it appears to do the following:
    $^W = 1;
    Which is the same as putting -w in your hash bang line. Basically, it turns on warnings. Right after the 'use XML::Mini::Document;' you could put:
    $^W = 0;

    The other option is to fix the warnings, assuming they are coming from your code. You should always work with use strict; and use warnings; on. If your script is barking, it's probably for a reason.

    Good luck.

      ok, im working through some of the warnings, and i have a question. is this not valid:
      my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime +(time); my $dateTime = $hour,":",$min,":",$sec," ",$mday,"/",$mon+1,"/",$y +ear+1900,"";
      when i run my program, i get this for output:
      Useless use of a constant in void context at C:\Perl\test\Dev\AutoSI\autoSI.pl line 98.
      Useless use of private variable in void context at C:\Perl\test\Dev\AutoSI\autoSI.pl line 98.
      Useless use of a constant in void context at C:\Perl\test\Dev\AutoSI\autoSI.pl line 98.
      Useless use of private variable in void context at C:\Perl\test\Dev\AutoSI\autoSI.pl line 98.
      Useless use of a constant in void context at C:\Perl\test\Dev\AutoSI\autoSI.pl line 98.
      Useless use of private variable in void context at C:\Perl\test\Dev\AutoSI\autoSI.pl line 98.
      Useless use of a constant in void context at C:\Perl\test\Dev\AutoSI\autoSI.pl line 98.
      Useless use of addition (+) in void context at C:\Perl\test\Dev\AutoSI\autoSI.pl line 98.
      Useless use of a constant in void context at C:\Perl\test\Dev\AutoSI\autoSI.pl line 98.
      Useless use of addition (+) in void context at C:\Perl\test\Dev\AutoSI\autoSI.pl line 98.
      Useless use of a constant in void context at C:\Perl\test\Dev\AutoSI\autoSI.pl line 98.
      anyhelp would be great. thanks

        You should probably log back in when you post a follow-up.

        Anyway, no, it's not valid. Try changing all the commas to dots:

        my $dateTime = $hour.":".$min,":".$sec," ".$mday."/".$mon+1."/".$ye +ar+1900."";
        Or you can change $dateTime to @dateTime, and put the whole RHS in parenthesis:
        my @dateTime = ($hour,":",$min,":",$sec," ",$mday,"/",$mon+1,"/",$y +ear+1900,"");
        Of course, doing that changes how you use it as well. I'm guessing you want the first one. Note that you may also just find it easier to use sprintf:
        my $dateTime = sprintf "%02d:%02d:%02d %02d/%02d/%d", $hour, $min, $sec, $mday, $mon+1, $year+1900;

        PS - I'm not sure why you have that ending empty string - you should be able to get rid of it.

        Well, run it and see if $dateTime is set to what you expect. On my system, it's set to 16, which is probably not what you expect. The comma seperates arguments to a function, or if not used in a function call, executes all of the statements listed. In this case, it's first executing:
        my $dateTime = $hour
        then
        ":"
        then
        $min

        Neither : nor $min will do anything, so Perl complains this probably isn't what you wanted.

        Probably you meant to use the dot operator (.) to concatenate these together as strings, or else use the strings as arguments to join.