Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

v-string in use/require non-portable

by Anonymous Monk
on May 16, 2004 at 03:19 UTC ( [id://353722]=perlquestion: print w/replies, xml ) Need Help??

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

Dear All,

I have a question about perl and need your help. I have a perl script which use MIME::Lite to send email to a mailbox server. Here are some lines:

$mime_msg = MIME::Lite->new( From => '1001@151.104.234.7', To => '1002@151.104.234.7', Subject => 'test', Type => 'text/html', Data => $message); MIME::Lite->send('smtp', '151.104.234.7'); $mime_msg->send();

This program works fine. But after I install module MIME::Parser for retireving attachment. Accurately say after installing MailTool (when I run perl script, I was asked to insatll MailTool), the above lines can not go through. I got the error:

"unrecognised line: '1002@151.104.234.7' (eval 8) at line 6."
Also I got such error when I run my perl script:
v-string in use/require non-portable at /usr/lib/perl5/site_perl/5.8.0/MIME/Field/ParamVal.pm line 65.
Anyone has an idea about this problem? Thanks in advance! Quency

Edited by Chady -- added code tags, and some formatting.

Replies are listed 'Best First'.
Re: v-string in use/require non-portable
by andyf (Pilgrim) on May 16, 2004 at 09:31 UTC
    I have seen this before
    v-string in use/require non-portable at /usr/lib/perl5/site_perl/5.8.0/MIME/Field/ParamVal.pm line 65.
    and I think it's just a grumble or a warning you can ignore. Try removing any -w flags and it will probably go away. As for the other error, which looks more serious, I don't know. Good luck,
    Andy.

      The warning is coming from this line of Mail::Field::ParamVal:

      require v5.6;

      Such a line no longer causes a warning in more recent perls, but you can avoid the problem either by modifying the above line to read:

      require 5.006;
      or with something like this in your own code:
      BEGIN { no warnings 'portable'; require Mail::Field::ParamVal; }
      .. to make sure the offending module is loaded and compiled early, with that particular warning disabled.

      Beware that taking the latter approach has a small chance of causing you problems in the future, if a later version of perl detects some other portability problem in the module that you would have wanted to know about.

      The other workaround, of course, is to upgrade to the latest maintenance version of perl 5.8, currently 5.8.4.

      Hugo

        I don't think that workaround will work; since the "no warnings" is lexically scoped, it will have no effect on ParamVal.pm.

        MIME::Field::ParamVal doesn't use warnings itself, so it is only warning because the original poster running using the -w switch (or is turning on warnings with the $^W variable.) Removing the -w and putting "use warnings" in the main script instead should fix the problem (by disabling any warnings from all modules that didn't explicitly enable them), as would:

        BEGIN { local $^W = 0; require MIME::Field::ParamVal; }
        Incidentally, this warning is removed as of 5.8.1, but is still in bleadperl; is this intentional?
        Hugo, Thanks for your help. I will try the ways you suggested. Do you think if I do what you suggested me to do, this will make my perl script run correctly. The script was running correctly before, after I install MailTool module, it can not run and give a error message: "Unrecoginzed lines '1001@151.104.234.7'" in the method MIME::Lite->new. So previously running script now can not run anymore. Do you think how I can slove this problem? Thanks again, Quency
Re: v-string in use/require non-portable
by exussum0 (Vicar) on May 16, 2004 at 08:46 UTC
    I went to the author's site, and found that he will soon not support MIME::Lite anymore.

    Feel free to ask me questions, but please be aware that I am in the process of handing off development/maintenance to anyone who wants it. I simply can't deal with patches, feature requests, or new bugs.
    ----

    Update: corion informs me demerphq is the maintainer now.

Re: v-string in use/require non-portable
by demerphq (Chancellor) on May 17, 2004 at 12:41 UTC

    I'm guessing that when you installed MIME::Parser you also installed Mail::Address (part of the Mail-Tools distro) which actually is the recommended way to use MIME::Lite. I'm very suprised that Mail::Address parses less well than MIME::Lite itself does, even though I did beef up MIME::Lite's fallback parsing in v3.01. Anyway, there are a few options to bypass this behaviour. You can use an approach like hugo recommended, you can uninstall or delete Mail::Address, you can add a version number higher than Mail::Address currently has to the MIME::Lite code, or probably easiest:

    BEGIN{ $MIME::Lite::Paranoid=1; } use MIME::Lite;

    Which will cause MIME::Lite to bypass loading non core external modules. This mode is a little less well tested than the normal load-em-if-you-got-em approach but hopefully should still work effectively. Ill probably add a special option that disables the loading of things like Mail::Address to the next release.

    Anyway, I hope this helps.


    ---
    demerphq

      First they ignore you, then they laugh at you, then they fight you, then you win.
      -- Gandhi


      Demerphq, Hugo, and anyone else I am very appreciative of all your help. I try disabling the loading of Mail::Address, the script works now. Thanks again, Quency

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://353722]
Approved by Old_Gray_Bear
Front-paged by bart
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found