September 04, 2003
Quick filter

Gav said this in his journal:

I've always liked that Perl has a .= operator but I've often wished for the reverse. Why isn't there something nice like $x ,= $y (meaning $x = "$y$x" )?

So, during the commercial during Inuyasha, I did this:

package Foo;

use Filter::Util::Call;
sub import {
  my ($type) = @_ ;
  my $ref = [] ;
  filter_add(bless $ref) ;
}

sub filter {
  my ($self) = @_ ;
  my $status = filter_read();

  if (/\s+=.\s+/) {
    s!^(\$[[:alnum:]_]+)\s+=.\s+(\$[[:alnum:]_]+)!$1 = $2 . $1!;
  }

  $status;
}

1;

And this script:


use Foo;

my $foo = " World";
my $bar = "Hello";

$foo =. $bar;
print $foo . "\n";

$zog =.1;
print $zog;

Which, when run, produces:


Hello World
0.1

Now, if everything could be solved during commercial breaks!!! I did it with =. and not ,= since =. is the opposite of .=.

Posted by Kevin at September 04, 2003 05:10 PM
Comments
Post a comment

Leave a comment