Damian Conway writes:
 > Micholas Clarke asked:
 > 
 > > If a subroutine explicitly needs access to its invocant's topic, what is so
 > > wrong with having an explicit read-write parameter in the argument list that
 > > the caller of the subroutine is expected to put $_ in?
 > 
 > Absolutely nothing. And perfectly legal. You can even call that rw parameter $_
 > if you like:
 > 
 >      sub get($id_obj, $_ is rw) {
 >          when "who"     { return $id_obj.name }
 >          when "choose"  { return any($id_obj.features).pick }
 >          when "all"     { return $id_obj.features }
 >      }
 > 
 >      for «name choose all» {
 >          print get($obj, $_);
 >      }
 > 

Just ( my ) terminology clean-up : in this example sub{ } is implicit
topicalizer ( it does not set $_ explicitly ) , and you are setting $_ 
for perl . that's why you can use "when" . 


???

is this valid ? 
(morning() is function that analyse stringifyed time ) 

#!/usr/bin/perl -w 

when ~time ~~ &morning { print "good morning" }

__END__

and also 
 

#!/usr/bin/perl -w 
$_ = ~time
when &morning() { print "good morning" }

__END__


arcadi .

Reply via email to