>>>>> "TL" == Thomas Liebezeit <goo...@liebezeit.de> writes:

  TL> I'm triying to do some substitutions on an  pdf file.

  TL> perl -p -i~ -w -e "s/A/B/;" file.pdf

  TL> This works as intended, except:  perl adds 0x0D (Windows \n)  :-/
  TL> as a  HEX diff shows.
  TL> How can I work around this? Is there something like binmode()?

there isn't a binmode option for the command line. you would need to
call binmode from the oneliner and that makes it more than a typical one
liner. write a real but short script to do this. in fact, you can use a
new version of File::Slurp that can do that in one call. check this out
(untested):


use File::Slurp qw( edit_file ) ;

my $file = shift or die "missing file argument" ;

edit_file { s/A/B/g } $file, { binmode => ':raw' } ;


you could even reduce that to a one liner if you must (also untested):

perl -MFile::Slurp=edit_file -e 'edit_file { s/A/B/g } shift, { binmode => 
":raw" }' foo.pdf


note that i added the /g option to the s/// op to replace all A with B
in the pdf. you did it on a line by line basis and it would only change
the first occurance in a line. alter to your needs.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to