I have a prototype that seems to be failing... or perhaps it's beeing ignored. Posted below is an excerpt from an object oriented module I'm writing (Reference: Data Validation Tests, further reference listed in there)

sub selftest(@){ my $self = _self(@_); print Dumper(@_); } sub _self(\@){ print Dumper(@_); if(ref($_[0]->[0]) && $_[0]->[0]->_me() eq 'DVALID'){ return shift(@{ $_[0] }); }else{ return; } }
This is the test proggy:
my $chk = new Data::Validate::OO( -failure => sub{ my $rule = shift; print "Error in rule '$rule': ". +join(', ',@_)."\n"; }, ); $chk->selftest(qw(This Is a Test of the emergency broadcast system!));
This is the output:
$VAR1 = bless( { '_error' => '', '_fail' => sub { "DUMMY" }, '_rules' => {} }, 'Data::Validate::OO' ); $VAR2 = 'This'; $VAR3 = 'Is'; $VAR4 = 'a'; $VAR5 = 'Test'; $VAR6 = 'of'; $VAR7 = 'the'; $VAR8 = 'emergency'; $VAR9 = 'broadcast'; $VAR10 = 'system!'; Not an ARRAY reference at OO.pm line 264.


Line 264 is the if(ref($_[0]->[0]) && $_[0]->[0]->_me() eq 'DVALID'){ line.

Now, according to perlman:perlsub "Any backslashed prototype character represents an actual argument that absolutely must start with that character. The value passed as part of @_ will be a reference to the actual argument given in the subroutine call, obtained by applying \ to that argument." Reading this, it seems to me that I should be getting a reference to the @_ of the caller sub. Unfortunately that apparently isn't happening... unless I messed up somewhere else (which is quite possible).

If there is any more information you feel might help to solve the problem, please request it and I will do my best to take care of it.

Thank you.



My code doesn't have bugs, it just develops random features.

Flame ~ Lead Programmer: GMS | GMS


In reply to Prototype Failing? by Flame

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.