Ok guys, SomeHow I got lost in this mess, and I think I might need more
help. The values inside my switch are  not properly calculated , and when I
try to round down it go's into the default statment. Can you please look
what I cam up with again and see where I am going wrong.

#!/usr/bin/perl -w
use POSIX;
$CYLLENGTH=16065;

open (PW_FH,"| fdisk -f -") || die " cant popn fdisk ";
sleep(1);

print "enter partition                  : "; chomp ( $P_num=<> );
print "enter partition type [165 BSD]   : "; chomp ( $P_type=<> );
print "enter partition start cylender   : "; chomp ( $P_start=<> );
print "enter partition length [cylenders]: "; chomp ( $P_length=<> );


while( ( $Remainder = ($P_length%$CYLLENGTH) ) != 0 ){
  print "\asize you gave is not multiple of cylenders\n";
  print "round (U)p (D)own (R)enter ?"; chomp ($Ans=<>);

for ($Ans){
 /u/i && do { $P_length -= $Remainder += $CYLLENGTH } && last;
 /d/i && do{ $P_lenght -= $Remainder } && last;

#default
 print "enter partition length        : " ; chomp ($P_lenght=<>)

; last;




}


}
print " $P_length is the value \n";
_exit 0; # take this out once fixed

print PW_FH "p $P_num $P_type $P_start $P_lenght";

close PW_FH;

_exit 0;

Thanx in advance,
 Mark
----- Original Message -----
From: "Hanson, Rob" <[EMAIL PROTECTED]>
To: "'Mark Goland'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, October 11, 2002 3:34 PM
Subject: RE: switch


> Ooops, I think I misunderstood the question in my last post.  That will
> teach me to read the whole post first!
>
> Anyway...
>
> What does that $where in your code come from?  It is in the for()
statement.
> Shouldn't it be $Ans?
>
> I would do it more like this...
>
> print "Enter the command: ";
> chomp(my $input = <STDIN>);
>
> for ($input) {
>   /u/i and print "u\n" and last;
>   /d/i and print "d\n" and last;
>
>   # default
>   print "default\n";
> }
>
> ....You need the "and last", otherwise it will always execute the default.
>
> Rob
>
>
> -----Original Message-----
> From: Mark Goland [mailto:[EMAIL PROTECTED]]
> Sent: Friday, October 11, 2002 3:20 PM
> To: [EMAIL PROTECTED]
> Subject: switch
>
>
> 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]
>
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to