"Did you upgrade Perl"

probably, Further, Switch was removed from the core in Perl 5.14 http://stackoverflow.com/questions/2630547/why-is-the-switch-module-deprecated-in-perl

so first they got the message Can't locate Switch.pm in @INC (you may need to install the Switch module), Searched the tree and found a Switch.Pm under CGI, and added use CGI::Switch;, which didnt help a bit.

ok, so since Switch.pm is no longer core, and i didnt want to install it (being depreciated anyway), i took this http://cpansearch.perl.org/src/RGARCIA/Switch-2.16/Switch.pm and put it in its own directory, and then put this into the same directory

#!perl -w use strict;use warnings; use Switch; sub Main { Switch {print "hi\n";return;} }
and glory be got
hi
Why, i dunno?

ok it wasnt that simple. first i tried

#!perl -w use strict;use warnings; use Switch; Switch {my $a=1};
and got
Can't locate object method "Switch" via package "1" (perhaps you forgo +t to load "1"?) at switch.pl line 4.
Thinking that all those returns were the reason i went to
#!perl -w use strict;use warnings; use Switch; Switch {my $a=1;return};
and got
Can't return outside a subroutine at switch.pl line 4.
AHAH, the reason for the sub Main {}

so i cant figure out what Switch {} is doing. there is no sub Switch in Switch.pm (there is a sub switch tho). I figure it has something to do with use Filter::Util::Call and the import and filter subroutines. Can anyone give me a clue?

edit:fixed case in "Can't locate switch.pm" from a typo/wrong-copy-paste

edit2: ok i think i got it if a class is used to invoke the method, that argument will be the name of the class.http://docstore.mik.ua/orelly/perl/prog3/ch12_03.htm. so Switch {} is trying to invoke method Switch with an argument (without parens) that is the result of a block, but the block "never ends?" due to the return. Is that it?


In reply to Re^4: Switch.pm Failure ( CGI::Switch? ) by huck
in thread Switch.pm Failure by tultalk

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.