Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!uwm.edu!psuvax1!news From: flee@shire.cs.psu.edu (Felix Lee) Newsgroups: comp.lang.perl Subject: Re: quasi-bug Message-ID: Date: 28 Mar 90 17:21:12 GMT References: <1121@etnibsd.UUCP> <15290@bfmny0.UU.NET> Sender: news@cs.psu.edu (Usenet) Organization: Penn State Computer Science Lines: 16 Perl is kinda dangerous in many ways. I once wanted to parse multiple '-e expr' and '-f file' options the way 'sed' does, with or without a space between the option and the argument. Without much thought, I wrote the following, which handles the optional space in a single statement: while ($_ = shift) { &expression($1 || shift), next if (/^-e(.*)$/); &file($1 || shift), next if (/^-f(.*)$/); # ... } Unfortunately, this doesn't work properly for '-e0', '-f0', or '0'. If strings weren't converted to numbers in boolean contexts . . . -- Felix Lee flee@shire.cs.psu.edu *!psuvax1!flee