jeudi 23 janvier 2014

Re: Regex replacement via external command topic




Rainer Weikusat <(E-Mail Removed)> writes:

[...]


> Contrived example which can actually be executed:
>
> -----------------
> undef $/;
> my $input = <STDIN>;
>
> for ($input) {
> /\G(x+)/gc and do {
> my $fh;
>
> open($fh, '| tr x y');


This is sort-of a silly example pipe because the output would be
identical when everything was just piped through tr. A slightly less
silly example would be

open($fh, '| sed "s/./y/g"');

This uses sed to replace every input byte with an y. As can easily be
verified, it only runs for x in the input, not for any other character.





Aucun commentaire:

Enregistrer un commentaire