i m getting runtime error ,i can,t understand ,please check it out

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • creation
    New Member
    • Sep 2013
    • 1

    i m getting runtime error ,i can,t understand ,please check it out

    Code:
    $b= 1;
    while($b)
    {
    	$a = <>;
    	if($a eq 42)
    		break;
    	else
    	{
    		print $a;
    	}
    	
    }
    Last edited by RonB; Sep 15 '13, 02:10 PM. Reason: Added code tags
  • RonB
    Recognized Expert Contributor
    • Jun 2009
    • 589

    #2
    What did the error message say?

    The break keyword is not used to exit a while loop. It's used to break out of a "given()" block. Use last to break out of a while loop.
    perldoc -f break
    perldoc -f last

    $a and $b are built-in global vars used in sort routines and it's best not to us them outside of that context.

    Input received via the <> operator will include the line terminator at the end of that data which should be removed. That is done via the chomp function.
    perldoc -f chomp

    Comment

    Working...