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

Hi all,

My goal is to convert MS .msg files generate by Outlook to mime so I can read the messages on linux. I found this article:

http://wiki.sabayonlinux.org/index.php?title=HOWTO:_Read_Microsoft_Outlook_.MSG_files_in_Linux

The cpan deps are:

perl -MCPAN -e 'install("Email::Outlook::Message")'

perl -MCPAN -e 'install("Email::LocalDelivery")'

perl -MCPAN -e 'install("Getopt::Long")'

perl -MCPAN -e 'install("Pod::Usage")'

perl -MCPAN -e 'install("File::Basename")'

The last one "File::Basename" has been quite difficult for me. My opensuse 11.0 system has perl 5.10.0 , so I get a message like this (I lost the history but its similar):

The most recent version "2.77" of the module "File::Basename" is part of the perl-5.8.9 distribution. To install that, you need to r +un force install File::Baseline --or-- install N/NW/NWCLARK/perl-5.8.9.tar.gz

I seen a similar error on this forum and it mentioned something about getting the .pm and .t files for the git repo, but I'm not sure how to build those. What I decided to do was build 5.8.9 from source so that I'd have both 5.10.0 and 5.8.9 on my system. So I did:

wget http://search.cpan.org/CPAN/authors/id/N/NW/NWCLARK/perl-5.8.9.tar.bz2

And did a "make" and "make install" . Bad idea!!! It trashed my 5.10.0 install and now all my printing via hplib is broken, among other things. Assuming I can revert to 5.10.0 somehow, what is the easiest way to install "File::Basename" on a system with perl 5.10.0 ?

Replies are listed 'Best First'.
Re: "File::Basename" problems
by toolic (Bishop) on Aug 03, 2009 at 16:11 UTC
    what is the easiest way to install "File::Basename" on a system with perl 5.10.0 ?
    File::Basename is a core module. It should already be installed. What happens when you try this?
    perldoc File::Basename

    Getopt::Long and Pod::Usage are also core modules, by the way.

      Hmm, the only way I can get perl 5.10.0 now is via the absolute path "/usr/bin/perl5.10.0" , as "/usr/bin/perl -v" says its 5.8.9. "perldoc File::Basename" gives me something similar to a manpage, but is that from the 5.8.9 version on my system? I saw no 5.10.0 path for perldoc on my system. Anyways, I get this error now:

      /home/iksrazal/Documents> /usr/bin/perl5.10.0 msgconvert.pl mymessage.msg

      Unknown DIR entry MsoDataStore

      Unknown FILE entry SummaryInformation

      Unknown property 1039

      Unknown property 10F3

      Please help
        is that from the 5.8.9 version on my system?
        This will show you the full directory path of the module file:
        perldoc -l File::Basename

        My guess is that those error messages are coming from your msgconvert.pl file, which you have not shown here.

Re: "File::Basename" problems
by Khen1950fx (Canon) on Aug 03, 2009 at 21:37 UTC
    You have to use the full path to perl5.10.0 because, when you installed perl5.8.9, you must have run: rm -f config.sh Policy.sh. By doing that, you made perl5.8.9 the main perl; hence, 5.10.0 isn't your system perl anymore. Because the config.sh and Policy.sh of 5.10.0 was removed, you'll have to reinstall 5.10.0, removing the config.sh and Policy.sh for 5.8.9, if you want 5.10.0 to be the system perl.

    One other thing, be very careful when authors list dependencies. They don't really make any distinction between core and site modules. The best thing to do, especially when you're just starting out, is use the CPAN shell. It'll take care of the dependencies for you.

    One good way of telling if a module is core is to use corelist. For example from the command-line:

    corelist File::Basename

    It'll tell you if it's core or not. You could also get a list of core modules starting with File:: like this

    corelist /^File::/ and it'll list the core modules starting with File::.

      Hi all, I went on vacation and I'm back on trying to make this work.

      I tried the following:

      /usr/src/perl-5.8.9> make uninstall make: *** No rule to make target `uninstall'. Stop.

      So I added this bash alias to get 5.10.0 for now:

      alias perl='/usr/bin/perl5.10.0'

      I also ran:

      /root> corelist /^File::/ | grep -i basename

      File::Basename was first released with perl 5

      linux-df3s(root)

      /root> perl -v

      This is perl, v5.10.0 built for i586-linux-thread-multi

      I reran all the cpan installs. I continue to get:

      /home/iksrazal/Documents> /usr/bin/perl5.10.0 msgconvert.pl mymessage.msg

      Unknown DIR entry MsoDataStore

      Unknown FILE entry SummaryInformation

      Unknown property 1039

      Unknown property 10F3

      Googling turns up nothing on those errors. Here is the contents of msgconvert.pl , which I got from http://www.matijs.net/software/msgconv . Please help.

      #!/usr/bin/perl -w

      #

      # msgconvert.pl:

      #

      # Convert .MSG files (made by Outlook (Express)) to multipart MIME messages.

      #

      use Email::Outlook::Message;

      use Email::LocalDelivery;

      use Getopt::Long;

      use Pod::Usage;

      use File::Basename;

      use vars qw($VERSION);

      $VERSION = "0.902";

      # Setup command line processing.

      my $verbose = '';

      my $mboxfile = '';

      my $help = ''; # Print help message and exit.

      GetOptions(

      'mbox=s' => \$mboxfile,

      'verbose' => \$verbose,

      'help|?' => \$help) or pod2usage(2);

      pod2usage(1) if $help;

      # Check file names

      defined $ARGV[0] or pod2usage(2);

      foreach my $file (@ARGV) {

      my $mail = new Email::Outlook::Message($file, $verbose)->to_email_mime->as_string;

      if ($mboxfile ne '') {

      Email::LocalDelivery->deliver($mail, $mboxfile);

      } else {

      my $basename = basename($file, qr/\.msg/i);

      my $outfile = "$basename.mime";

      open OUT, ">$outfile"

      or die "Can't open $outfile for writing: $!";

      print OUT $mail;

      close OUT;

      }

      }

      #

      # Usage info follows.

      #

      __END__

      =head1 NAME

      msgconvert.pl - Convert Outlook .msg files to mbox format

      =head1 SYNOPSIS

      msgconvert.pl options <file.msg>...

      Options:

      --mbox <file> deliver messages to mbox file <file>

      --verbose be verbose

      --help help message

      =head1 OPTIONS

      =over 8

      =item B<--mbox>

      Deliver to the given mbox file instead of creating individual .mime

      files.

      =item B<--verbose>

      Print information about skipped parts of the .msg file.

      =item B<--help>

      Print a brief help message.

      =head1 DESCRIPTION

      This program will convert the messages contained in the Microsoft Outlook

      files <file.msg>... to message/rfc822 files with extension .mime.

      Alternatively, if the --mbox option is present, all messages will be put in

      the given mbox file. This program will complain about unrecognized OLE

      parts in the input files on stderr.

      =head1 BUGS

      The program will not check whether output files already exist. Also, if you

      feed it "foo.MSG" and "foo.msg", you'll end up with one "foo.mime",

      containing one of the messages.

      Not all data that's in the .MSG file is converted. There simply are some

      parts whose meaning escapes me. One of these must contain the date the

      message was sent, for example. Formatting of text messages will also be

      lost. YMMV.

      =head1 AUTHOR

      Matijs van Zuijlen, C<matijs@matijs.net>

      =head1 COPYRIGHT AND LICENSE

      Copyright 2002, 2004, 2006, 2007 by Matijs van Zuijlen

      This program is free software; you can redistribute it and/or modify

      it under the same terms as Perl itself.

      =cut

Re: "File::Basename" problems
by halfcountplus (Hermit) on Aug 03, 2009 at 19:35 UTC
    And did a "make" and "make install" . Bad idea!!! It trashed my 5.10.0 install and now all my printing via hplib is broken, among other things. Assuming I can revert to 5.10.0 somehow,
    Unpack the 5.8.9 tarball again (if necessary) and "make uninstall". They are both there and will not have corrupted one another.