On Jun 30, Scott, Joshua said:

>What is the best way to stop the processing of a subroutine if an error is
>found without exiting the entire program?  For example, I've got a
>subroutine that reads from a file and processes each line.  I know to use
>the following code if I want to stop processing the program:

To end a subroutine, just use return().

>open(FILE,"somefile.txt") or die "ERROR\n";
>
>How do I simply stop processing the subroutine, and not the entire program?
>Can I have multiple statements after the "or"?

You can put a do {} block after the or if you have a lot to get done:

  open FOO, "bar" or do {
    # this
    # that
    return;
  };

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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

Reply via email to