Diary SiteMap RecentChanges About Contact 2009-08 Calendar

Search:

Matching Pages:

2009-08-03 Strange Perl Issue

Today I had to make the following change to Oddmuse because that fixes an image upload issue on my dad’s blog. What’s going on? He’s using the following:

Any ideas? The net result was that <$file> resulted in no content if run within the eval block.

*** wiki.pl.~1.925.~	Fri Jul  3 11:23:01 2009
--- wiki.pl	Tue Aug  4 00:20:26 2009
***************
*** 3548,3554 ****
      $type = $q->uploadInfo($filename)->{'Content-Type'};
      ReportError(T('Browser reports no file type.'), '415 UNSUPPORTED MEDIA TYPE') unless $type;
      local $/ = undef;   # Read complete files
!     eval { require MIME::Base64; $_ = MIME::Base64::encode(<$file>) };
      $string = '#FILE ' . $type . "\n" . $_;
    } else {
      $string = AddComment($old, $comment) if $comment;
--- 3548,3555 ----
      $type = $q->uploadInfo($filename)->{'Content-Type'};
      ReportError(T('Browser reports no file type.'), '415 UNSUPPORTED MEDIA TYPE') unless $type;
      local $/ = undef;   # Read complete files
!     my $content = <$file>; # Apparently we cannot count on <$file> to always work within the eval!?
!     eval { require MIME::Base64; $_ = MIME::Base64::encode($content) };
      $string = '#FILE ' . $type . "\n" . $_;
    } else {
      $string = AddComment($old, $comment) if $comment;

Tags:

Read Comments (2)

Show Google +1