Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: grep and find file weirdness

by graff (Chancellor)
on Jun 21, 2007 at 04:23 UTC ( [id://622481]=note: print w/replies, xml ) Need Help??


in reply to grep and find file weirdness

Since you seem to be on a *n*x machine, seems like this would be a lot simpler (assuming a bash shell):
$ find /tmp/rja/find_test -type f -print0 | perl -0 -ne 'chomp; $t=do{local $/; open(T,"<",$_);<T>}; print "$_ is completely CRLF\n" unless ( $t =~ /(?<!\r)\n/ )'

But then, I've never been a fan of File::Find, ever. It's just too weird and too slow.

BTW, are you looking for files that are completely CRLF, as I assumed in my snippet, or rather for files that have any CRLF in them? If the latter, the last part of the snippet would be  if ( $t =~ /\r\n/ ) update: and I'd change "is completely" to "has".

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-18 02:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found