Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Odd number of elements in anonymous hash

by BillKSmith (Monsignor)
on Jun 09, 2016 at 18:19 UTC ( [id://1165246]=note: print w/replies, xml ) Need Help??


in reply to Re: Odd number of elements in anonymous hash
in thread Odd number of elements in anonymous hash

I think $attached should be a hash ref.
use strict; use warnings; use Data::Dumper; my $code = 1; my $file_name = 'my_file_name'; my $email = 'to@address.com'; my $from = 'from@address.com'; my $from_name = 'Me'; my $subject = 'try_me'; my $body = 'Here is my message.'; my $attached = ($code) ? { attach_path => $file_name, attach_filename => $file_name, attach_type => 'application/txt', } : {} ; my %args = ( to => $email, from => $from, from_name => $from_name, subject => $subject, body => $body, %$attached ); my $success = email(%args); sub email { # Display arguments; my %arg_hash = @_; print Dumper(\%arg_hash); ... } OUTPUT: $VAR1 = { 'attach_path' => 'my_file_name', 'from' => 'from@address.com', 'subject' => 'try_me', 'from_name' => 'Me', 'attach_filename' => 'my_file_name', 'to' => 'to@address.com', 'attach_type' => 'application/txt', 'body' => 'Here is my message.' }; Unimplemented at C:\Users\Bill\perl\monks\email.pl line 38
Bill

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1165246]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-19 05:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found