I know this is probably a noob question, but I just can't figure out why this is happening like it is. I'm simply trying to deref the value of something inside a system() call. When run, the script pulls mail via IMAP, parses the mail for any TIFF images, converts them to postscript, and prints them via lpr. In this example, it prints out the filename instead. The result:
[jason@lappy ~]$ perl parser.pl
/tmp/FAX206984492211_9529539900-14.TIF
MIME::Entity=HASH(0x80f74a8)->bodyhandle->path
Any idea why the reference in the double-quotes isn't interpreted as I'd expect? I know I've done this sort of thing with other scripts, I assume that I'm just not dealing with the data structure I'd expect (MIME::Parser doesn't document the bodyhandle->path method).
#!/usr/bin/perl
use strict;
use Net::IMAP::Simple;
use MIME::Parser;
my $out_dir = "/tmp";
+
+
my $server = new Net::IMAP::Simple('localhost');
$server->login('testuser','password');
my $parser = MIME::Parser->new;
$parser->output_dir($out_dir);
+
+
# Create Archive folder if non-existent
$server->select('Archive') || $server->create_mailbox('Archive');
+
+
# Grab number of messages
my $number_of_messages = $server->select('INBOX');
+
+
# Print messages, copy to Archive, delete message
foreach my $msg (1..$number_of_messages) {
my $msg_fh = $server->getfh($msg);
my $entity = $parser->parse($msg_fh);
for my $part ($entity->parts) {
if ($part->mime_type =~ /tiff/) {
print $part->bodyhandle->path, "\n";
print "$part->bodyhandle->path\n";
}
}
$entity->purge;
#$server->copy($msg,'Archive');
#$server->delete($msg);
}
+
+
$server->quit;
-fp