Adam R. Frielink wrote:

> I've had some trouble with a commandline syntax for a string search and
> replace using a perl command line.
> 
> My cmd line was:
> 
> perl -pi -e 's!\xae!\&\#169!g' <list of files>

I tried this on tcsh and cmd.exe.  cmd.exe needs "s instead of 's and
tcsh doesn't like ! and Perl wants a backup ext :

perl -pi.bak -e "s{\xae}{&#169}g" foo

> This did not replace the occurace hex EA

You mean AE ?

> The script for what that above cmd line should compile into (according
> to the Camel Book) is:
> 
> __BEGIN__
> #!perl.exe
>     $extension = '*';
>     LINE: while (<>) {
>         if ($ARGV ne $oldargv) {
>             if ($extension !~ /\*/) {
>                 $backup = $ARGV . $extension;
>             }
>             else {
>                 ($backup = $extension) =~ s/\*/$ARGV/g;
>             }
>             rename($ARGV, $backup);
>             open(ARGVOUT, ">$ARGV");
>             select(ARGVOUT);
>             $oldargv = $ARGV;
>         }
>         s/\xae/\&\#169\;/g;
>     }
>     continue {
>         print;  # this prints to original filename
>     }
>     select(STDOUT);
> __END__
> 
> Running this actual script works, but not the commandline version.  Did
> I not escape the commandline properly?
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to