Luke Palmer wrote:
I would, from the descriptions, imagine that:
 @keep <~ grep /good/ <~ @list ~> grep /bad!/ ~> @throw;

Would parse as:
 @keep <~ grep /good/ <~ @list;
 @list ~> grep /bad!/ ~> @throw;

Nope.  <~ and ~> only *rearrange* arguments, so if you only type @list
once, you can only do things that you could before when you typed
@list only once.
So what we have is (using a scalar for an arbitrary variable) is:

$a ~> subroutine $arg1;

is equivalent to:

subroutine $arg1, $a;

and

subroutine $arg1 <~ $a;

is equivalent to:

subroutine $arg1 $a:; # or , equivalently, subroutine $a: $arg1;

and

.. ~> $a;

is equivalent to

$a = ...;

and similarly,

$a <~ ...;

is equivalent to

$a = ...;

~> is left associative, <~ right associative, have the same precedence, and can't be mixed in one expression because of conflicting associativity

That means that a standard chain like:

@list ~> grep /good/ ~> map -> { s/good/bad/ } ~> @badlist;

would parse as
((@list ~> grep /good/) ~> map -> { s/good/bad/ } ) ~> @badlist;
to
((grep /good/ @list) ~> map -> {s/good/bad/ } ) ~> @badlist;
to
(map -> {s/good/bad/}, (grep /good/ @list)) ~= @badlist;
to
@badlist = (map -> {s/good/bad/}, (grep /good/ @list));
to
@badlist = map -> {s/good/bad/}, grep /good/ @list;

(modulo possible regex sytax).




Reply via email to