Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Perl Switch Errors on certain version

by broquaint (Abbot)
on Nov 29, 2005 at 10:07 UTC ( #512556=note: print w/ replies, xml ) Need Help??


in reply to Perl Switch Errors on certain version

If you're having problems with Switch you could always use Switch::Perlish instead e.g

switch $subkey => sub { case 1, sub {$acc = $messagebin{$file}{$subkey}; if($debug){&writelog(3,"DEBUG: Account=$acc");}}; case 11, sub {$ordid = $messagebin{$file}{$subkey}; if($debug){&writelog(3,"DEBUG: OrderId=$ordid");}}; case 14, sub {$lotsfill = $messagebin{$file}{$subkey}; if($debug){&writelog(3,"DEBUG: LotsFilled=$lotsfill");}}; case 31, sub {$fillprice = $messagebin{$file}{$subkey}; if($debug){ &writelog(3,"DEBUG: FillPrice=$fillprice");}}; case 32, sub {$lotsact = $messagebin{$file}{$subkey}; if($debug){ &writelog(3,"DEBUG: LotsActioned=$lotsact");}}; case 34, sub {$transno = $messagebin{$file}{$subkey}; if($debug){&writelog(3,"DEBUG: TransNo=$transno");}}; # As 35 can contain execution report, we make sure we can h +andle them. case 35, sub {my $new = $messagebin{$file}{$subkey}; if($new =~ m/D/i){$action = "New";if($debug){&writelog(3,"D +EBUG: Action=$action");}} elsif($new =~ m/G/i){$action = "Amend";if($debug){&writelog +(3,"DEBUG: Action=$action");}} elsif($new =~ m/F/i){$action = "Cancel";if($debug){&writelo +g(3,"DEBUG: Action=$action");}} elsif($new =~ /9/){$action = "Reject";if($debug){&writelog( +3,"DEBUG: Action=$action");}} elsif($new =~ /8/){$action = "Report";if($debug){&writelog( +3,"DEBUG: Action=$action");}} }; case 37, sub {$dborderid = $messagebin{$file}{$subkey}; if($debug){&writelog(3,"DEBUG: DBOrderId=$dborderid");}}; case 38, sub {$lotsordered = $messagebin{$file}{$subkey};; if($debug){&writelog(3,"DEBUG: LotsOrdered=$lotsordered");} +}; case 40, sub {$ordertype = $messagebin{$file}{$subkey}; if($debug){&writelog(3,"DEBUG: OrderType=$ordertype");}}; case 41, sub {$amedorderid = $messagebin{$file}{$subkey}; if($debug){&writelog(3,"DEBUG: AmendOrderId=$amedorderid"); +}}; case 44, sub {$orderprice = $messagebin{$file}{$subkey}; if($debug){&writelog(3,"DEBUG: OrderPrice=$orderprice");}}; case 50, sub {$traderid = $messagebin{$file}{$subkey}; if($debug){&writelog(3,"DEBUG: TraderId=$traderid");}}; case 54, sub {my $bs = $messagebin{$file}{$subkey}; if($bs == 1){$buysell = "Buy";if($debug){&writelog(3,"DEBUG +: BuySell=$buysell");}} elsif($bs == 2){$buysell = "Sell";if($debug){&writelog(3,"D +EBUG: BuySell=$buysell");}} }; case 55, sub {$consid = $messagebin{$file}{$subkey}; if($debug){&writelog(3,"DEBUG: Contract=$consid");}}; case 100, sub {$exchange = $messagebin{$file}{$subkey}; if($debug){&writelog(3,"DEBUG: Exchange=$exchange");}}; case 150, sub {my $new1 = $messagebin{$file}{$subkey}; if($new1 == 0){$filltype = "Ack";if($debug){&writelog(3,"DE +BUG: Action=$action");}} elsif($new1 =~ /1/){$filltype = "Part Fill";if($debug){&wri +telog(3,"DEBUG: Action=$action");}} elsif($new1 =~ /2/){$filltype = "Full Fill";if($debug){&wri +telog(3,"DEBUG: Action=$action");}} elsif($new1 =~ /3/){$filltype = "Done for Day";if($debug){& +writelog(3,"DEBUG: Action=$action");}} elsif($new1 =~ /4/){$filltype = "Ack Cancel";if($debug){&wr +itelog(3,"DEBUG: Action=$action");}} elsif($new1 =~ /5/){$filltype = "Ack Amend";if($debug){&wri +telog(3,"DEBUG: Action=$action");}} elsif($new1 =~ /6/){$filltype = "Pending Cancel";if($debug) +{&writelog(3,"DEBUG: Action=$action");}} elsif($new1 =~ /7/){$filltype = "Stopped";if($debug){&write +log(3,"DEBUG: Action=$action");}} elsif($new1 =~ /8/){$filltype = "Rejected";if($debug){&writ +elog(3,"DEBUG: Action=$action");}} elsif($new1 =~ /9/){$filltype = "Suspended";if($debug){&wri +telog(3,"DEBUG: Action=$action");}} elsif($new1 =~ m/A/i){$filltype = "Pending new";if($debug){ +&writelog(3,"DEBUG: Action=$action");}} elsif($new1 =~ m/B/i){$filltype = "Calculated";if($debug){& +writelog(3,"DEBUG: Action=$action");}} elsif($new1 =~ m/C/i){$filltype = "Expired";if($debug){&wri +telog(3,"DEBUG: Action=$action");}} elsif($new1 =~ m/D/i){$filltype = "Restated";if($debug){&wr +itelog(3,"DEBUG: Action=$action");}} elsif($new1 =~ m/E/i){$filltype = "Pending Replace";if($deb +ug){&writelog(3,"DEBUG: Action=$action");}} else{$filltype = "Unknown";if($debug){&writelog(3,"DEBUG: A +ction=$action");}} }; case 151, sub {$lotsstillopen = $messagebin{$file}{$subkey}; if($debug){&writelog(3,"DEBUG: LotsOpen=$lotsstillopen");}} +; case 200, sub {$maturity = $messagebin{$file}{$subkey}; if($debug){&writelog(3,"DEBUG: Maturity=$maturity");}}; };
The syntax is slightly different because it's just standard perl code and ought to achieve the same result, but with less syntactical magic.
HTH

_________
broquaint


Comment on Re: Perl Switch Errors on certain version
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://512556]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (17)
As of 2015-07-02 17:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (44 votes), past polls