Re: Switch.pm Failure
by haukex (Archbishop) on Feb 24, 2017 at 05:57 UTC
|
I am confused by your question: As far as I can tell, CGI::Switch (which apparently has been deprecated for a long time - what version are you using?) doesn't provide a switch method. The use of Switch is not recommended, and even if you are using it, I don't think your syntax switch { is correct.
Could you tell us where you're getting switch from, and try to boil down the code that fails for you into an SSCCE?
| [reply] [d/l] [select] |
Re: Switch.pm Failure
by huck (Prior) on Feb 24, 2017 at 02:49 UTC
|
There is a whole lot missing from that example, like two right braces at least. is switch supposed to be a label?
switch: {
warn("manage_users.cgi line 54 '$action'");
#Request from User for Login Form
($action eq "GetLoginForm") && do {
manageusers::OpenConnection();
}
}
or a call to the switch method in CGI::Switch?
http://search.cpan.org/~chips/perl5.004/lib/CGI/Switch.pm
CGI::Switch - Try more than one constructors and return the first object available
my $q = new CGI::Switch;
Added:
or use of the plain switch module?
http://search.cpan.org/~chorny/Switch-2.17/Switch.pm
use Switch;
switch ($val) {
case 1 { print "number 1" }
case "a" { print "string a" }
case [1..10,42] { print "number in list" }
case (\@array) { print "number in list" }
case /\w+/ { print "pattern" }
case qr/\w+/ { print "pattern" }
case (\%hash) { print "entry in hash" }
case (\&sub) { print "arg to subroutine" }
else { print "previous case not true" }
}
I originally discounted this because of the lack of the switch constructs like case, but decided to add it too | [reply] [d/l] [select] |
|
|
Please, don't recommend Switch. Being a source filter, it causes more problems than it solves. Maybe you just wanted to point to it for completeness, or because that might be what the OP had in mind, but then it still lacks the warning.
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord
}map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
| [reply] [d/l] |
|
|
I didnt mean to recommend it, it was a sortof completeness thing. The partial example didnt match much, nothing like a call to CGI:switch, lacking a last switch; like a labeled block might use, and lacking the test-variable/case of the source filter, and with statements inside the block too. I added it as an after thought just in case it was what was meant.
| [reply] [d/l] |
|
|
|
|
|
|
|
|
|
|
|
I relied yesterday with the whole block of code. I don't see the post How long does it take a moderator to approve or does that occur ordid I screw up?
??
| [reply] |
Re: Switch.pm Failure ( CGI::Switch? )
by Anonymous Monk on Feb 24, 2017 at 03:57 UTC
|
CGI::Switch hasn't been a "thing" for at least 20 years | [reply] |
|
|
Hi:
The question I think is not complicated and does not involve
all the reasons I should not be using switch.
This program was working for years. Now the message:
Can't call method switch without a package or object reference.
I have done searches all over on this message and find nothing but elaborate answers.
I have used CGI::Search and the package is in my system.
So why would the code be unacceptable now and it was not
previously. I did comment out use strict to see if that was the culprit. It was not.
I am dead in the water.
| [reply] |
|
|
"This program was working for years."
I doubt it, somebody changed something
"I have used CGI::Search"
even if you meant CGI::Switch, that has nothing to do with "Switch" the way you used it. CGI::Switch was a way to replace the $query=new CGI; statement you have somewhere. my $query = new CGI::Switch; "Per default the new() method tries to call new() in the three packages Apache::CGI, CGI::XA, and CGI. It returns the first CGI object it succeeds with." http://search.cpan.org/~chips/perl5.004/lib/CGI/Switch.pm. CGI::Switch has nothing to do with how the word "Switch" was used here. If you have some sort of versioning system i would go back and look at what existed in the past.
My bet is that once there was a colon after Switch, or what @haukex noted about a Switch subroutine somewhere Re^5: Switch.pm Failure
A lot of places ive worked that dont have versioning systems ive created a simple program to make a new backup copy of production code everytime the modified date changed. And everytime someone came to me saying "It stopped working and i didnt change anything" i was able to go into this archive and show them the change THEY made that made it stop working now.
| [reply] [d/l] [select] |
|
|
So why would the code be unacceptable now and it was not previously.
Well, what has changed on your server? Did you upgrade Perl, and/or the CGI module, or anything else?
| [reply] |
|
|
|
|
|
|
|
|
|
|