Re: Loop controls

2002-05-02 Thread Damien Neil
On Wednesday, May 1, 2002, at 02:27 PM, Aaron Sherman wrote: > unless my $fh = $x.open { > die "Cannot open $x: $!"; > } else while $fh.getline -> $_ { > print; > } else { > die "No lines to read in $x"; > } I think you need a bet

Re: Loop controls

2002-05-02 Thread Aaron Sherman
On Wed, 2002-05-01 at 18:47, Damien Neil wrote: > On Wednesday, May 1, 2002, at 02:27 PM, Aaron Sherman wrote: > > unless my $fh = $x.open { > > die "Cannot open $x: $!"; > > } else while $fh.getline -> $_ { > > print; > > } else { > > die "No lines

eval {} or carp "blah: $@"

2002-05-02 Thread Jim Cromie
with p5, Ive often written eval {} or carp "$@ blah"; it seems to work, and it reads nicer (to my eye) than eval {}; if ($@) {} but I surmise that it works cuz the return-value from the block is non-zero, for successful eval, and 0 or undef when block dies, not cuz of magical treatment of $@

Re: eval {} or carp "blah: $@"

2002-05-02 Thread Luke Palmer
On Thu, 2 May 2002, Jim Cromie wrote: > > with p5, Ive often written > > eval {} or carp "$@ blah"; > > it seems to work, and it reads nicer (to my eye) than > > eval {}; if ($@) {} > > but I surmise that it works cuz the return-value from the block is non-zero, > for successful eval, and 0

Re: eval {} or carp "blah: $@"

2002-05-02 Thread Dave Mitchell
On Thu, May 02, 2002 at 02:33:42PM -0600, Jim Cromie wrote: > > with p5, Ive often written > > eval {} or carp "$@ blah"; You generally Don't Want To Do That. If the eval succeeds, but the last statement in the eval happens to come out as false, then it'll still carp: $a = 0; eval { 1 < $a

Re: Loop controls

2002-05-02 Thread Damian Conway
> Um... I know it's scary, but I can actually imagine using this (or > something like this) in development. I'll occasionally work on a section > of code I'm not ready to integrate yet. It would be nice to be able to > syntax check it without uncommenting and re-commenting the whole thing. > :) Y

Re: eval {} or carp "blah: $@"

2002-05-02 Thread Peter Scott
At 02:33 PM 5/2/02 -0600, Jim Cromie wrote: >eval {} or carp "$@ blah"; > >it seems to work, and it reads nicer (to my eye) than > >eval {}; if ($@) {} % perl -le 'eval { print "No exceptions here"; 0 } or warn "$@ blah"' No exceptions here blah at -e line 1. -- Peter Scott Pacific Systems De

Re: eval {} or carp "blah: $@"

2002-05-02 Thread Damian Conway
Jim Cromie wrote: > with p5, Ive often written > > eval {} or carp "$@ blah"; > > it seems to work, modulo any block that returns false :-( > and it reads nicer (to my eye) than > > eval {}; if ($@) {} > > but I surmise that it works cuz the return-value from the block is non-zero, > f