Quantcast
Viewing all articles
Browse latest Browse all 16232

shell programming and scripting

hi,
i am trying this while loop and i only want that it should only read food as pizza....no other entry should be taken here.

Code:

#!/usr/bin/perl -w

$food = " ";

while ( $food ne 'pizza' )
{
  print 'enter what you had last night: ';
  chomp ($food = <STDIN>);
  #print $food ;
}

print "Mmm....it was yummy \n";

this is what the result i get after running this particular script, that the loop does not end and tht i have to terminate the session.
Code:

enter what you had last night: mango
enter what you had last night: pizza
enter what you had last night: tomato
enter what you had last night: potato 
enter what you had last night:

this loop dpes not end as the way it should have ended.

thanks
kullu

Viewing all articles
Browse latest Browse all 16232

Trending Articles