Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!wuarchive!julius.cs.uiuc.edu!apple!agate!shelby!portia.stanford.edu!achille@portia.StanFord.EDU From: eillihca@embezzle.StanFord.EDU ( Achille Hui, the Day Dreamer ) Newsgroups: comp.lang.perl Subject: Help for a new-born perl user.... Message-ID: Date: 15 Jan 91 09:42:17 GMT Sender: news@portia.Stanford.EDU Distribution: comp Organization: Dept. of Physics, Stanford University. Lines: 45 X-Transfer-Agent: portia.stanford.edu (NNTP) I have just compiled perl3.0@44 on our dept. machines and start to write perl-scripts, then I encounter the following two problems: 1) consider the following pieces of codes: if(open(pp,"|less")){ while($_ = <>){ printf(pp "%s",$_); } close(pp); } If I pump a lot of data into and exit the program ( less in this case ) before it exhausts all those data, the perl script simply die prematurely... I discover when I try to close the pipe in the script , perl will try to flush remaining data onto the pipe. If the other end close the pipe first, a SIGPIPE will be generated.... Is it more sensible that `` close '' will return will an indication of error instead of simply bumping me out ???? Of course, I can avoid this by sandwiching the while loop and the close statement with a signal handler on SIGPIPE. But this is sort of gloss ... Is there more elegant way to handle this ? 2) how to tell a given string is a valid regular expression or not ? Basically, I want to get a regular expression $pattern from an user and matches it with a fixed list of strings and do something on them.. while($_ = shift(@strings)){ if ( $_ =~ /^$pattern/ ){ ... doing something ..... } } However, if the user accidentally type in a malformed regular expression, perl will kick me out again.... In general, is there a way to make perl ignore such ``fatal'' error ? +--------------------------------+ +------------------------+ | eillihca@embezzle.StanFord.EDU | | Achille Hui +--------------------| -01/15/91- | | The Day Dreamer... | Dept. of Physics, +--------------------------------+ +---------------------| Stanford University. | +-----------------------+