I have this observation on when I read your post. First, the error I am getting seems to be different on my version, "perl 5.10.0 for MSWin32" when I run your code, I think the "not scalar dereference" or "not private variable" don't really reflect the same thing (that is debatable as I want to garner views on this from our revered monks).

A "variable" can be any one of the Perl variables we know of and in this case perl thinks it is supposed to be "private" -When I read your post I thought you were making a private subroutine to another subroutine- and which you just happened to not dereference as it should have been. Whereas a "scalar" is a sigil-preceded entity so in your case perl thinks you're passing a scalar dereference which might not be clear enough of a message !.

That's just an observation which I hope I can stand corrected and be clarified about.

#replicating the Origianl Post (strictures on): my $coderef = sub {print "Hi There \n";}; sub doit(&){ &{$_[0]}; } doit($coderef); #accessing a code ref from within a subroutine #Without prototype-check disabling..
#The same perl complaint is generated in the above code too C:\Documents and Settings\m>perl - sub testit{ print 'hi' };; sub doit (&) { $_[0]->() };; my $codeRef = \&testit;; doit( $codeRef );; __END__ Type of arg 1 to main::doit must be block or sub {} (not private varia +ble) at - line 4, near "$codeRef )" Execution of - aborted due to compilation errors.


Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.

In reply to Re: The & prototype and code references in scalars. by biohisham
in thread The & prototype and code references in scalars. by BrowserUk

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.