You can clone with
# This is intended as an easy-to-use cookbook example to getting started
# uploading files on Perl. Please let me (gaurav at ggvaidya dot com) know
# if you have any comments or suggestions for this example.
# It is made available under the same license terms as the Perl interpreter.
my $mech = new WWW::Mechanize(
autocheck => 1 # If set to 1, WWW::Mechanize will produce its
# own error messages.
# For more information on how $file works, please check out
# see http://search.cpan.org/perldoc?HTTP::Request::Common#POST
my $file = [
'filename-on-disk.txt', # The file you'd like to upload.
'filename-for-upload.txt', # The filename you'd like to give the web server.
'Content-type' => 'text/plain' # Any other flags you'd like to add go here.
'Content_Type' => 'form-data',
'Content' => [
'upload' => $file