You could use a ternary operator here: $Ans =~ m/u/i ? print "u\n" : $Ans =~ m/d/i ? print "d\n" : $Ans =~ m/r/i ? print "r\n" : (some default);
:) >===== Original Message From Mark Goland <[EMAIL PROTECTED]> ===== >Hi guys, > >I am trying to implement a switch statment in perl. I have tryed doing it 2 >way's. For some reason my comparison statments are not working can some one >please look over my code and see if they can point me on the right track ?? > >Thanx in advance, >Mark > >Solution 1: > >while( ( $Remainder = ($P_lenght%16065) ) != 0 ) >{ > print "\a size you gave is not multiple of cylenders\n"; > print "round (U)p (D)own (R)enter ?"; $Ans=<>; ># chomp ($Ans); >print $Ans; >for ($where){ >/u/ && do{print "u\n";}; >/d/ && do{print "d\n";}; ># default >print "enter partition length : "; >chomp ( $P_lenght=<> ); > > >} >} >_exit 0; > >solution 2: > >while( ( $Remainder = ($P_lenght%16065) ) != 0 ) >{ > print "\a size you gave is not multiple of cylenders\n"; > print "round (U)p (D)own (R)enter ?"; $Ans=<>; ># chomp ($Ans); >print $Ans; >if( $Ans =~ /u/i ){ >$P_lenght = ($P_lenght - $Remainder+$CYLLENGTH); >} >elsif( $Ans =~ /d/i){ >$P_lenght-=$Remainder; >} ># default >else{ >print "enter partition length : "; chomp ( $P_lenght=<> ); >} > > >} > >_exit 0; > > > > >-- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]