james28909 has asked for the wisdom of the Perl Monks concerning the following question:
i have this file in binmode (its hex bin) and its only 190 or so kb,
the file size varies but that really doesnt matter.
what i am trying to do is open the file in read mode, then find all instances
of FF*16 or (FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF) and delete it,
but only FF*16 because there are other instances of just FF or FF FF and i would like to leave those instances and just delete FF*16. here is the code i have so far:
i hope you understand what i am treing to do, and thank you for any help i recieve :)
EDIT: $file =~ s{\xFF{16}}{}g; worked great.
the file size varies but that really doesnt matter.
what i am trying to do is open the file in read mode, then find all instances
of FF*16 or (FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF) and delete it,
but only FF*16 because there are other instances of just FF or FF FF and i would like to leave those instances and just delete FF*16. here is the code i have so far:
i had some help and figured out that $file =~ s/\0{16}//g; works great for 00's, but it doesnt work for FF's -.-open($infile, '<', './file') or die "cannot open file: $!"; binmode $infile; open($outfile, '>', './modifiedfile') or die "cannot open modifiedfile +: $!"; binmode $outfile; local $/; $file = <$infile>; $file =~ tr/\FF*{16}//d; print $outfile $file; close ($infile); close ($outfile);
i hope you understand what i am treing to do, and thank you for any help i recieve :)
EDIT: $file =~ s{\xFF{16}}{}g; worked great.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: delete FF's from a file
by Corion (Patriarch) on Feb 11, 2013 at 09:18 UTC | |
by james28909 (Deacon) on Feb 11, 2013 at 09:26 UTC | |
by james28909 (Deacon) on Feb 11, 2013 at 09:27 UTC | |
by Corion (Patriarch) on Feb 11, 2013 at 09:30 UTC | |
by Anonymous Monk on Feb 11, 2013 at 09:30 UTC | |
Re: delete FF's from a file (perlquote)
by Anonymous Monk on Feb 11, 2013 at 09:28 UTC | |
by james28909 (Deacon) on Feb 11, 2013 at 09:30 UTC | |
Re: delete FF's from a file
by Lotus1 (Vicar) on Feb 11, 2013 at 15:25 UTC | |
Re: delete FF's from a file
by igelkott (Priest) on Feb 11, 2013 at 09:32 UTC | |
by james28909 (Deacon) on Feb 11, 2013 at 09:41 UTC | |
by tmharish (Friar) on Feb 11, 2013 at 10:14 UTC | |
by igelkott (Priest) on Feb 11, 2013 at 15:09 UTC | |
by tmharish (Friar) on Feb 12, 2013 at 13:59 UTC | |
by Anonymous Monk on Feb 11, 2013 at 09:47 UTC | |
by james28909 (Deacon) on Feb 11, 2013 at 09:56 UTC | |
by james28909 (Deacon) on Feb 11, 2013 at 09:46 UTC | |
by Anonymous Monk on Feb 11, 2013 at 09:38 UTC |
Back to
Seekers of Perl Wisdom