Update: Answered my own question. It has to be Devel::Declare->setup_for(...) not Devel::Declare::setup_for(...)

Does anyone know what do I have to change in this:

package Cswitch; use strict; use warnings; use Devel::Declare; sub import { print "Import called with @_"; my $class = shift; my $caller = caller; Devel::Declare::setup_for( $caller, { switch => { const => \&pSwitch }, case => { const => \&pcase }, } ); no strict; *{ $caller . '::switch' } = sub () { }; *{ $caller . '::case' } = sub () { }; } sub pSwitch { print "pSwitch: @_"; } sub pCase { print "pCase: @_"; } 1;

In order that this would cause the parser subs to be called:

#! perl -slw use strict; use Cswitch; switch 1, { case 1, { print 'Got 1'; }; case 2, { print 'Got 2' }, };

to stop this?

C:\test>t-DevDec.pl Import called with Cswitch Number found where operator expected at C:\test\t-DevDec.pl line 5, ne +ar "switch 1" (Do you need to predeclare switch?) Number found where operator expected at C:\test\t-DevDec.pl line 6, ne +ar "case 1" (Do you need to predeclare case?) Number found where operator expected at C:\test\t-DevDec.pl line 9, ne +ar "case 2" (Do you need to predeclare case?) syntax error at C:\test\t-DevDec.pl line 5, near "switch 1" Execution of C:\test\t-DevDec.pl aborted due to compilation errors.

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"

In reply to Re: Is Devel::Declare really so much less evil than source filters? (Solved) by BrowserUk
in thread Is Devel::Declare really so much less evil than source filters? by moritz

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.