On Oct 18, Chris Benco said: >Script seems to work well. I can send it blank fields and it recovers >every time. Problem is when I leave it running it crashes with the now >infamous Can't use an undefined value as a hash reference At line 16. When >it does this there is nothing in the inbox to process. I added 'or ()' to >get around this problem, which seems to work when I send it blank fields.
(You should really turn on warnings in your program. The -w switch, or 'use warnings' if you have Perl 5.6 or higher.) The 'or ()' is doing NOTHING. First of all $x = 0 or 2; is parsed as ($x = 0) or 2; and not as $x = (0 or 2); Second, it'd be better to use "" instead of an empty list. Third, the error is about the HASH reference, not a string. The method is returning something that is not a hash reference: > my $From = $Document->GetFirstItem('From')->{Text} or (); # This You want to do: my $From = ($Document->GetFirstItem('From') || {})->{Text} || ''; Or perhaps: my $empty = { Text => "" }; # then: my $From = ($Document->GetFirstItem('From') || $empty)->{Text}; You could use $empty with all the other fields, too. Or, make your own function! # get_item($Document, 'From'); # get_item($Document, 'From', 'Text'); # explicit 'Text' field sub get_item { my ($doc, $item, $field) = @_; if (my $data = $doc->GetFirstItem($item)) { return $data->{$field || "Text"}; } warn "$item not found" if $^W; return ""; } -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]