Hello

I recently wrote some code which worked fine on my development machine (Windows, developed in Eclipse using Epic plugin, Perl v5.10.0) but failed (in production, of course) on a Solaris box, Perl v5.8.8. There are various reasons the code wasn't tested prior to production in an as-live scenario ...

I'd like to understand why this failed so I don't make the same (or similar) mistake in future.

I wrote:
my $self->{_dbh} = $dbh; $self->{_sth} = $sth; bless $self, "xxx"; return $self;
On the Solaris box this failed with: Can't use an undefined value as a HASH reference On Windows ... not a whimper. I am using strict and warnings and had run the code through perlcritic (-3).

I resolved this by ...

my $self = {}; ... $self->{_dbh} = $dbh; $self->{_sth} = $sth; bless $self, "xxx"; return $self;

I'm new to Perl but not programming & I get the idea of the error message but I don't understand why it should work on one platform and not the other.

Is it a platform issue? And if so, where can I do some reading on cross platform issues (& how to avoid them)?

Is it a version of Perl issue?

And is my solution acceptable or have I done something bad/wrong here too?

In reply to Windows/Solaris Difference by azp74

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.