The example below is just a test, I need to be able to insert multiple values into a command, those values can be either 1, 2 or upto 5.
Below is closer to the working example, but I will read that document and to help make a final decision. # Check Free PV's operation_CHECKFREEPVS(); $NEWMIRROR = $MIRROR + $numPV; if ($numPV ne 0 && $MIRROR le 5) { # lvextend print "$numPV $NEWMIRROR $MIRROR\n"; switch ($numPV) { case 1 { run("/usr/sbin/lvextend -m $NEWMIRROR -s $sourcelv $FreePV[0]"); } case 2 { run("/usr/sbin/lvextend -m $NEWMIRROR -s $sourcelv $FreePV[0] $FreePV[1]"); } case 3 { run("/usr/sbin/lvextend -m $NEWMIRROR -s $sourcelv $FreePV[0] $FreePV[1] $FreePV[2]"); } case 4 { run("/usr/sbin/lvextend -m $NEWMIRROR -s $sourcelv $FreePV[0] $FreePV[1] $FreePV[2] $FreePV[3]"); } case 5 { run("/usr/sbin/lvextend -m $NEWMIRROR -s $sourcelv $FreePV[0] $FreePV[1] $FreePV[2] $FreePV[3] $FreePV[4]"); } } # lvsync run("/usr/sbin/lvsync -T $sourcelv"); logprint "Successful $NEWMIRROR mirrors \t\t synced"; } else { cleanexit (10, "FAIL \t\t No Free PV's Available"); } return 0; } ________________________________ From: John W. Krahn <jwkr...@shaw.ca> To: Perl Beginners <beginners@perl.org> Sent: Wednesday, 1 August 2012 4:58 PM Subject: Re: case statement in perl Paul.G wrote: > Below is an extract from the perl script, the switch/case statement seemed > like a simple solution. > > > > ##################### Mail Program ##################################### > > operation_CHECKFREEPVS(); > print "$numPV \n"; > # print "$FreePV[1] $FreePV[0] $numPV\n"; > if ($numPV ne 0 ) { > 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"; } > } > } Couldn't you just do that like this: if ( @FreePV && @FreePV <= 3 ) { print join( ' ', @FreePV ), "\n"; } > else { > print "No PV's available \n"; > } John -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/