Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: delete FF's from a file

by igelkott (Priest)
on Feb 11, 2013 at 09:32 UTC ( #1018116=note: print w/replies, xml ) Need Help??

in reply to delete FF's from a file

Several issues with this. Here are a few hints:

  • The first arg (file handle) for for open is usually bare (no $)
  • Your search is made for a plain text file, not binary data.
  • Your regular expression is way off (no offence): "\F", "F" and the 16 counts of strings of any length
  • 16 FF's would be 'FF' x 16 ... if you were going for a text string rather than binary data

You should review common "regular expressions" and then searching binary data in particular.

Replies are listed 'Best First'.
Re^2: delete FF's from a file
by james28909 (Deacon) on Feb 11, 2013 at 09:41 UTC
    so i can open with filehandle "infile" without "$"?
    yes, it is a dump from hardware, but i guess you could call it plain text as it can be opened in notepad but has wild characters.
    i tried many different variations of $file =~ and nothing would work out.
    i am fixing to read up on the link that was posted earlier.
    thanks for all the help
      so i can open with filehandle "infile" without "$"?

      You CAN but there are good some very good reasons not to.

      You will notice from the last link above the "Modern Perl", Recommended by Anonymous Monk below, does not use it.

      At the end of the day its a choice that you make but I disagree with igelkott on this.

      To differentiate you could always call it $input_file_handle or similar.

        filehandle "infile" without "$"

        I don't have an evidence to support my claim of "usually" but maybe that's not relevant anyway. Of course it's possible to use and I didn't mean to imply that it was wrong. There were just so many things that looked "odd" to me.

      FWIW, you should binmode if you want to treat your binary files as binary ( no newline translation )

      with open it would be  open my($infile), '<:raw', ... or die ...

      While you're in a learning mood, get a free copy of Modern Perl book, a loose description of how experienced and effective Perl 5 programmers work....You can learn this too.</b.

        yes yes, i did use binmode. thanks for the tips as well :)
      i have def bookmarked this site
      this seems to be the place i can learn alot from
      i will make me a spot in the corner
      you wont even know im here
Re^2: delete FF's from a file
by Anonymous Monk on Feb 11, 2013 at 09:38 UTC

    The first arg (file handle) for for open is usually bare (no $)

    It usually isn't, as barewords are global symbols, and lexicals are preferable in almost every situation

    You could make an argument about style (different things should look different), but you did not

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1018116]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2021-04-16 03:06 GMT
Find Nodes?
    Voting Booth?

    No recent polls found