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

Dear monks,

I'm a young and inexperienced soul who has been trying to get to grips with the language of perl for just a year now and in particular I'm trying to extract attachments from incoming mails using MIME:Tools.

I have no problem getting the contents of the message but when I call the following:

$message  = $parser->parse_data($msg); # where $msg has already the email contents

I get

Undefined subroutine utf8::SWASHGET called at ./mime/MIME/Parser/Filer.pm line 364

This happens to be the first instance of regex matching in the Filer.pm file, so I'm assuming it's something to do with the way to regex matching is performed.

I put a regex match earlier just to see if it is indeed related to that and it failed on that exact spot with the same error.

My perl version is 5.8.9, MIME::Tools - 5.502, I'm not a root user and sadly have no access to root privileges (I'm getting around this by using

BEGIN { unshift @INC, "~email/mime"; }

at the top where /mime contains all the lib folders from the relevant CPAN modules, in this case MIME)

Thanks very much in advance!

P.S. I've posted this question on stackoverflow as well, as I felt that perl monks and SO have sufficiently different audiences, should it get answered in either one of the websites, I'll update both posts with the answer for future reference

Replies are listed 'Best First'.
Re: Getting utf8::SWASHGET when using MIME::Tools
by tobyink (Canon) on Jun 05, 2012 at 12:21 UTC
    SWASHNEW & SWASHGET are used by the regexp engine to categorise characters (e.g, is it a letter, punctuation, etc). You should rarely even notice that these functions exist. Perhaps Unicode is broken on your installation. (It ain't particularity awesome in 5.8 anyway.) Consider upgrading to a newer Perl. If you use perlbrew then it's crazily easy to do, and you don't need root.
    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

      Thanks you so much, unfortunately as I develop on a company product (that uses perl scripts) that must be compatible with the customer's environment, I don't think it will be possible to upgrade to a later version

      However, I accidentally managed to get that script to work by running it as bash$ perl script.pl instead of bash$ ./script.pl. Really bizarre but I guess something to be aware of :)

      Thanks for providing some background on my issue and I'll keep in mind your points on the way Perl 5.8 handles utf encoding if I come across a more persistent similar issue.

        Check your shebang line then. The perl being specified on the first line of your script (#!/path/to/perl) is not the first one in your path (which perl). Two different interpreters are being used, generating the different results.

        --MidLifeXis