Hi, On Wed, Aug 1, 2012 at 6:18 AM, Paul.G <medur...@yahoo.com.au> wrote:
> Below is an extract from the perl script, the switch/case statement seemed > like a simple solution. > ====> from perldoc -q switch <====== reads and I quote "...Starting from Perl 5.8, a source filter module, Switch, can also be used to get switch and case. Its use is now discouraged, because it's not fully compatible with the native switch of Perl 5.10, and because, as it's implemented as a source filter, it doesn't always work as intended when complex syntax is involved..." Seriously, I think you should do **perldoc -q switch** and read the documentation. It just a few lines. > ##################### Mail Program ##################################### > > operation_CHECKFREEPVS(); > print "$numPV \n"; > # print "$FreePV[1] $FreePV[0] $numPV\n"; > if ($numPV ne 0 ) { > I don't know your data, but with the expression above, are you sure you wouldn't get an error message. Is that not suppose to be if( $numPV != 0 ). Just saying... switch ($numPV) { > case 1 { print "$FreePV[0] \n"; } > case 2 { print "$FreePV[0] $FreePV[1] \n"; } > case 3 { print "$FreePV[0] $FreePV[1] $FreePV[2] \n"; } > } > } > else { > print "No PV's available \n"; > } > > > ________________________________ > From: Chris Nehren <c.nehren/beginn...@shadowcat.co.uk> > To: beginners@perl.org > Sent: Wednesday, 1 August 2012 2:54 PM > Subject: Re: case statement in perl > > On Tue, Jul 31, 2012 at 23:47:45 -0500 , Hal Wigoda wrote: > > Use the switch/case combination. > > > > On Tue, Jul 31, 2012 at 11:41 PM, Paul.G <medur...@yahoo.com.au> wrote: > > > Hi All > > > > > > > > > Does perl have a case statement or an equivalent? > > > > > > > > > Cheers > > > > > > Paul > > Don't use Switch.pm. It's a source filter and causes indeterministic > code evalution. See perldoc -q switch on a recent perl (5.12 or so or > above). Consider a dispatch table. > > -- > Chris Nehren | Coder, Sysadmin, Masochist > Shadowcat Systems Ltd. | http://shadowcat.co.uk/ > -- Tim