>>>>> "TC" == Tom Christiansen <[EMAIL PROTECTED]> writes:

  >> who uses select directly anymore? use a module! :)

  TC> I see the smiley, but one must be exceedingly careful not to
  TC> enshrine one's own personal preferences and predilections--one's
  TC> own small choices of style and nuance--into laws inviolate, and
  TC> then to further go on to hold others accountable for not having
  TC> followed those choices that one has made for oneself and then
  TC> dicated to others.

i am not as strict as you would think, but i haven't called 4 arg select
directly in a long time. IO::Select and Event.pm are too easy to use.

  TC>     ($this = $that) =~ s/foo/bar/;
  TC>     for (@these = @those) { s/foo/bar/ } 

  TC> You can't really do those in one step without it.

but do they really need to be combined into one step? i sometimes prefer
the separate assignment statement for clarity. other times i feel i am
in a compressing mood.

  TC> I have in passing proposed a form of s/// that acts upon a temporary
  TC> not the original and returns the new value not the success status.
  TC> This would employ the previously unused binary ~ operator (I mean
  TC> binary as in two operands; the unary ~ is bitwise, but I don't mean
  TC> that kind of binary.)  Were this around, one could write that first
  TC> one as

OT: use apl's monadic vs. dyadic instead of unary and binary. or just
say binary (as opposed to unary).


  TC>     $this = $that ~ s/foo/bar/:

  TC> Because the right side of the assignment is the string resulting
  TC> from that substitute, without harming $that.

that syntax is not clear about what gets into $this. obviously it is new
and unfamiliar but given my brain's perl syntax parser, i get confused
with that code.

  TC> By extension, the array case could be

  TC>     @these = map { $_ ~ s/foo/bar/ } @those

  TC> Which is still not very appealing, actually.  Hm... 

actually that is much more appealing to my taste. the syntax is not fun
but i like having a new list of modified stuff without needing to temp
copy each element. the fact that map $_ is aliased is the real problem
IMO. since it is not meant (hi abigail (who doesn't read this)) for use
in a void context, making $_ an alias so you can modify the args is
misleading. use the for modifier for that. so if $_ were a true copy of
the args, then map could do a s/// and return those new strings. 

but we need a better syntax for s/// that doesn't modify its string but
returns a copy which has had the substitution applied to it. possibly a
s/// modifier?

        $new = $old =~ s/foo/bar/n ;

n for new?

uri

-- 
Uri Guttman  ---------  [EMAIL PROTECTED]  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com

Reply via email to