Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8178487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:46:42+00:00 2026-06-06T23:46:42+00:00

I am using a service to send a picture to a server and they

  • 0

I am using a service to send a picture to a server and they require the image be converted to base64 format before it is sent. I tried MIME::Base64 with this code:

use MIME::Base64 ();

open (IMAGE, "C:\\wamp\\www\\image.png") or die "$!";

$base64_string = IMAGE;
$encoded = encode_base64($base64_string);
print "Encode $encoded";

and got this error message

Undefined subroutine &mqin::encode_base64 called at line 6.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:46:44+00:00Added an answer on June 6, 2026 at 11:46 pm

    When you specify an empty import list, like this:

    use MIME::Base64 ();
    

    You get no imports. That means that the function name encode_base64 will not be imported into the caller’s namespace. You can either allow for the import to happen, or fully qualify the function name by referring to the package it lives in explicitly when you call it.

    To import, change that line to:

    use MIME::Base64;
    

    The () parens are specifying that MIME::Base64 exports nothing to your namespace. The default behavior (without the parens) is to export encode_base64 and decode_base64. By using empty parenthesis in your import list you are overriding the convenient default behavior of importing those two function names. If you really don’t want those functions polluting your main namespace you could retain your original use MIME::Base64 () line, and then fully-qualify your subroutine call:

    $encoded = MIME::Base64::encode_base64($base64_string);
    

    But it’s a whole lot easier, and probably satisfactory to just allow the default export list to be processed by removing the parenthesis from your use line.

    Alternatively, you can specify exactly what to import:

    use MIME::Base64 ('encode_base64');
    

    This will import only the encode_base64 function, but will not import decode_base64, thereby minimizing namespace pollution.

    Update You’re also not reading the file. This line:

    $base64_string = IMAGE;
    

    …should be updated like this:

    $raw_string = do{ local $/ = undef; <IMAGE>; };
    $encoded = encode_base64( $raw_string );
    

    That problem would have been caught more verbosely if you had use strict 'subs' in effect. The problem is that “IMAGE” by itself is just a bareword, and Perl thinks it’s a subroutine call. The angle brackets, “<>” are the common way of reading from a filehandle. The “local $/ = undef” part is just a means of ensuring that you slurp the entire file, not just until the first sequence that looks like a “\n” to Perl.

    Update2: And as MOB points out, you either need to be escaping the backslashes in your path, or use forward slashes. Perl doesn’t mind, even on Win32. Of course since you’re taking the wise step of using or die $! on your open, you’ve already discovered this mistake.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am send data from one service to other service using parecable, when I
We are using a 3rd party email relay service to send mass emails to
I wrote REST service using ASP.NET Web API. I'm trying to send HttpDelete request,
I'm trying to send form fields and file to a web service using php
I need to send a file to a web service (ebridge) using their SendFile
Can we send emails from Rails application using Amazon SES SMTP service where sender's
i am using the gae xmpp service to send a chat message. all simply
I am building a service using WCF and I need to send over images.
I would like to have a REST web service using Apache CXF and send
I am using a service to send sms using php by redirecting to service

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.