On Tue, Nov 23, 2004 at 02:40:04PM -0800, Terrence Brannon wrote: > We all know that simple scalars can be chained together; > > $boolean = $this and $that or $the_other;
That's (($boolean = $this) and $that) or $the_other; which probably isn't what you meant and would give a "Useless use of a variable in void context" warning :) > It would be neat if there were some method-chaining syntax/module which > indicated "return false if your method call returns false": > > $object-?->method1-?->method2-?->method3 > > One solution appears to be Pipeline: > > http://search.cpan.org/~rclamp/Pipeline-3.12/lib/Pipeline.pm Er, I don't think so, but even if it is, that's a massive sledgehammer for this very small nut. > What I currently do is wrap the method chain in an eval block and check > to see if a Boolean was set within the block: > > { > my $boolean; > > eval { > $boolean = > GCt::glyph_attribute->retrieve > ( > glyph_type => $glyph_type, > attr_name => 'face_hideable' > ) > ->attr_value; > } > } > > push @status_options, 'hidden' if $boolean; > but that is much wordier than: > > push @status_options, 'hidden' if > GCt::glyph_attribute-?->retrieve( > glyph_type => $glyph_type, > attr_name => 'face_hideable' > ) > -?->attr_value; This seems just fine to me: push @status_options, 'hidden' if eval { GCt::glyph_attribute->retrieve( glyph_type => $glyph_type, attr_name => 'face_hideable' ) ->attr_value }; Tim. _______________________________________________ sw-design mailing list [EMAIL PROTECTED] http://metaperl.com/cgi-bin/mailman/listinfo/sw-design
