RE: RegEx to remove \x0D\x0A
Thank you for your help. Using binmode was indeed the solution. ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: RegEx to remove \x0D\x0A
More testing shows that... These two statements fail: print "\nYES\n" if $data =~ /\x0D/s; print "\nYES\n" if $data =~ /\x0d/s; These two statements succeed: print "\nYES\n" if $data =~ /\x0A/s; print "\nYES\n" if $data =~ /\x0a/s; As I stated before two different HEX editors show od oa sequences in my file and I can print the $data variable to STDOUT successfully. This is running ActiveState's build 633. ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: RegEx to remove \x0D\x0A
Got it (I think). Just add this after you open the file and before the read. binmode( FILE ); My tests on my machine agreed with you. -- Mike Arms > -Original Message- > From: Bullock, Howard A. [mailto:[EMAIL PROTECTED] > Sent: Wednesday, October 01, 2003 12:17 PM > To: 'Arms, Mike'; '[EMAIL PROTECTED]' > Subject: RE: RegEx to remove \x0D\x0A > > > More testing shows that... > > These two statements fail: > print "\nYES\n" if $data =~ /\x0D/s; > print "\nYES\n" if $data =~ /\x0d/s; > > These two statements succeed: > print "\nYES\n" if $data =~ /\x0A/s; > print "\nYES\n" if $data =~ /\x0a/s; > > As I stated before two different HEX editors show od oa > sequences in my file > and I can print the $data variable to STDOUT successfully. > > This is running ActiveState's build 633. > ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: RegEx to remove \x0D\x0A
Thank you. It appears that the "slurp" omits the \x0d character. Dir file size: 732 Perl length of $data: 704 Number of lines in the file: 28 Ok I thought that slurping was farely simple. print "Processing: $file"; if (open (INFILE, $file)) { { local $/; $data = ; close INFILE; print "\nlen=", length( $data ), "\n"; # print "data='$data'\n"; #fails: print "\nYES\n" if $data =~ /\x0D/s; } -Original Message- From: Arms, Mike [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 01, 2003 2:15 PM To: Bullock, Howard A. Subject: RE: RegEx to remove \x0D\x0A Did you add these two lines after reading in the file? print "len=", length( $data ), "\n"; print "data='$data'\n"; Does the length equal the file size? Do you see multiple lines? Both of these would indicate that you indeed slurped the whole file in correctly. ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: RegEx to remove \x0D\x0A
For #1 and #2 below: The file has data. I have examined it in two different Hex editors and printed it to the display. For #3: my script has 'local $/'. Outlook though it was being helpful. :( I guess a simple question is should this be working? If so, I will continue to work with it. -- 1. Make sure $data has any contents (i.e. the read worked as expected). Add these two lines. Does the length equal the file size? Do you see multiple lines? print "len=", length( $data ), "\n"; print "data='$data'\n"; 2. Make sure your file has CRLF's. I'd use Cygwin's "od" command. You should look for \r \n in the output of this command. od -c datafilename If the file was generated on a Mac, your probably see \r as line terminators. If the file was generated under Unix, your should see \n as line terminators. Some old oddball machines actually used \n \r. 3. Doh! Just noticed that you wrote: "Local $/;" . Maybe it is a typo or your email client auto capalitalized. It must be lowercase: local $/; -- Mike Arms ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: RegEx to remove \x0D\x0A
The final script will work against data file that I do not have. I am attempting to help someone else and hit this issue. The actual string to be removed is "\x20\x1B\x0D\x0A". In testing I can find the other characters but the RegEx engine does not seem to recognize the CRLF. You can use any text file for this test as I am only perplexed by the \x0D\x0A behavior. -Original Message- From: Peter Eisengrein [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 01, 2003 1:53 PM To: Bullock, Howard A.; '[EMAIL PROTECTED]' Subject: RE: RegEx to remove \x0D\x0A Are you sure they are CRLF's? And why regex? Why not chomp? Can you give us a bit of actual data? ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: RegEx to remove \x0D\x0A
Bullock, Howard A. [EMAIL PROTECTED] wrote: > My script slurps in a file > > Local $/; > $data = ; > > and want to remove the CRLF's. but even a simple RegEx match does not > succeed for me. > > These all have failed. > > print "\nYES\n" if $data =~ /\015\012/; > print "\nYES\n" if $data =~ /\015\012/s; > print "\nYES\n" if $data =~ /\x0D\x0A/; > print "\nYES\n" if $data =~ /\x0D\x0A/s; > print "\nYES\n" if $data =~ /\r\n/; > print "\nYES\n" if $data =~ /\r\n/s; > > What I am doing wrong? Without seeing more of the code, it is hard to say. But here's some approaches: 1. Make sure $data has any contents (i.e. the read worked as expected). Add these two lines. Does the length equal the file size? Do you see multiple lines? print "len=", length( $data ), "\n"; print "data='$data'\n"; 2. Make sure your file has CRLF's. I'd use Cygwin's "od" command. You should look for \r \n in the output of this command. od -c datafilename If the file was generated on a Mac, your probably see \r as line terminators. If the file was generated under Unix, your should see \n as line terminators. Some old oddball machines actually used \n \r. 3. Doh! Just noticed that you wrote: "Local $/;" . Maybe it is a typo or your email client auto capalitalized. It must be lowercase: local $/; -- Mike Arms ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: RegEx to remove \x0D\x0A
Title: RE: RegEx to remove \x0D\x0A Are you sure they are CRLF's? And why regex? Why not chomp? Can you give us a bit of actual data? -Original Message- From: Bullock, Howard A. [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 01, 2003 12:14 PM To: '[EMAIL PROTECTED]' Subject: RegEx to remove \x0D\x0A My script slurps in a file Local $/; $data = ""> and want to remove the CRLF's. but even a simple RegEx match does not succeed for me. These all have failed. print "\nYES\n" if $data =~ /\015\012/; print "\nYES\n" if $data =~ /\015\012/s; print "\nYES\n" if $data =~ /\x0D\x0A/; print "\nYES\n" if $data =~ /\x0D\x0A/s; print "\nYES\n" if $data =~ /\r\n/; print "\nYES\n" if $data =~ /\r\n/s; What I am doing wrong? ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs