I've been roaming thist site for some months now and always found answers to my questions without asking. Here's my first though:

My assignment at work was to make a small program that sends out about 9000 mail to customers of a client of ours.
Sending mail from a Perl-script is almost to easy to be true, so that is not my problem.

When I make a script/program I always try to make small test-scripts for each sub in the program.

I have a sub that reads an ini-file that returns a hash containing the ini-file settings and in the testscript it behaves just as expected.
When I move the EXCACT same code to the main script it fails with an error:
"Odd number of elements in hash assignment at SendMail.pl line 19."

The lvalues is of the same type to.
When I use Data::Dumper to print the hash returned from the sub it prints this:

$VAR1 = { '9/16' => undef };

Now, if the behaviour was consistent it would be something I could live with, but this really puzzles me.
Here's the best part:
When I return a reference from the sub it works like a charm (after changing the lvalue type and argument to Data::Dumper).

If someone knows what's going on here I would appreciate input on this.

Johnny

(Lucky for me there's more than one way to do it...)


In reply to Returning hash from sub by S3

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.