Re: Comparing files with regular expressions

2008-05-05 Thread Rob Dixon
Aaron Rubinstein wrote: > >> Given just the idea of the data, can you improve on that? > > I bet I could! I bet you could too :) > It's interesting how my instinct, when trying to develop a programming > solution, is to wrestle with the problem inside the context of the language. > As a result

Re: Comparing files with regular expressions

2008-05-05 Thread Aaron Rubinstein
> Given just the idea of the data, can you improve on that? I bet I could! It's interesting how my instinct, when trying to develop a programming solution, is to wrestle with the problem inside the context of the language. As a result, the solutions I come up with tend to be shaped by my limited

Re: Comparing files with regular expressions

2008-05-03 Thread Chas. Owens
On Sat, May 3, 2008 at 5:57 PM, Jenda Krynicky <[EMAIL PROTECTED]> wrote: > From: "Chas. Owens" <[EMAIL PROTECTED]> > > > On Sat, May 3, 2008 at 4:42 PM, Jenda Krynicky <[EMAIL PROTECTED]> wrote: > > snip > > > > [stuff about how two arg open is more dangerous than three arg open > > > And that

Re: Comparing files with regular expressions

2008-05-03 Thread Rob Dixon
rubinsta wrote: > Hello, > > I'm a Perl uber-novice and I'm trying to compare two files in order to > exclude items listed on one file from the complete list on the other > file. What I have so far prints out a third file listing everything > that matches the exclude file from the complete file (

Re: Comparing files with regular expressions

2008-05-03 Thread Jenda Krynicky
From: "Chas. Owens" <[EMAIL PROTECTED]> > On Sat, May 3, 2008 at 4:42 PM, Jenda Krynicky <[EMAIL PROTECTED]> wrote: > snip > > > [stuff about how two arg open is more dangerous than three arg open > > And that means you were lucky. If the $file contained something like > > "|rm -rf /" or "rm -rf

Re: Comparing files with regular expressions

2008-05-03 Thread Chas. Owens
On Sat, May 3, 2008 at 4:42 PM, Jenda Krynicky <[EMAIL PROTECTED]> wrote: snip > > [stuff about how two arg open is more dangerous than three arg open > And that means you were lucky. If the $file contained something like > "|rm -rf /" or "rm -rf / |" ... snip Nah, you would be lucky if that wer

Re: Comparing files with regular expressions

2008-05-03 Thread Jenda Krynicky
From: "Chas. Owens" <[EMAIL PROTECTED]> > On Fri, May 2, 2008 at 10:44 AM, rubinsta <[EMAIL PROTECTED]> wrote: > snip > > Any thoughts as to why > > some of the matches are getting missed? > snip > > Not off hand. I will extract your code and do some tests. Can you > send me y

Re: Comparing files with regular expressions

2008-05-02 Thread Chas. Owens
On Fri, May 2, 2008 at 10:44 AM, rubinsta <[EMAIL PROTECTED]> wrote: snip > Any thoughts as to why > some of the matches are getting missed? snip Not off hand. I will extract your code and do some tests. Can you send me your data or is it sensitive? snip > Just out of beginner curiosity, why

Re: Comparing files with regular expressions

2008-05-02 Thread rubinsta
Many thanks, Chas. These are all very helpful (and educational!) suggestions. I adapted your example like so (specifying the all.txt on the command-line): #!/usr/bin/perl use strict; use warnings; open my $ex, "<", "exclude.txt" or die $!; open my $out, ">", "exTest.txt" or die $!; my %exists;

Re: Comparing files with regular expressions

2008-05-02 Thread Chas. Owens
On Thu, May 1, 2008 at 4:09 PM, rubinsta <[EMAIL PROTECTED]> wrote: > Hello, > > I'm a Perl uber-novice and I'm trying to compare two files in order to > exclude items listed on one file from the complete list on the other > file. What I have so far prints out a third file listing everything >

Re: comparing files

2002-04-12 Thread Jerry Preston
Jenda, I want to which lines are different. Thanks, Jerry Jenda Krynicky wrote: > From: Jerry Preston <[EMAIL PROTECTED]> > > > I want to compare one file to another. Is it better to read the files > > line by line into an array or and hash or what is the best and or > > fastest? These file

Re: comparing files

2002-04-12 Thread Jenda Krynicky
From: Jerry Preston <[EMAIL PROTECTED]> > I want to compare one file to another. Is it better to read the files > line by line into an array or and hash or what is the best and or > fastest? These files are less than 100 lines. Depends on what do you mean by "compare". Do you want to get the

RE: comparing files

2002-04-12 Thread Nikola Janceski
[EMAIL PROTECTED]] > Sent: Friday, April 12, 2002 4:27 PM > To: 'Jerry Preston'; begginners > Subject: RE: comparing files > > > On UNIX it's called diff. >8^P > > > -Original Message- > > From: Jerry Preston [mailto:[EMAIL PROTECTED]] >

RE: comparing files

2002-04-12 Thread Nikola Janceski
On UNIX it's called diff. >8^P > -Original Message- > From: Jerry Preston [mailto:[EMAIL PROTECTED]] > Sent: Friday, April 12, 2002 4:23 PM > To: begginners > Subject: comparing files > > > I want to compare one file to another. Is it better to read the files > line by line into an arr

Re: Comparing files

2002-01-29 Thread Jason Purdy
*laugh* - Thanks for the pointers and consider myself better learned. :) Hmm ... now I better go & hunt down all those greps in my scripts... Jason If memory serves me right, on Tuesday 29 January 2002 13:26, Jeff 'japhy' Pinyan wrote: > On Jan 29, Jason Purdy said: > >my ( @filea, @fileb, @in

Re: Comparing files

2002-01-29 Thread Jeff 'japhy' Pinyan
On Jan 29, Jason Purdy said: >my ( @filea, @fileb, @inAButNotInB, @inBButNotInA ); I don't see any hashes being used. This feels like it's going to be very inefficient. >open ( FILEA, shift ) || die "Cannot open 1st file: $!\n"; >@filea = ; >close ( FILEA ); > >open ( FILEB, shift ) || die "C

Re: Comparing files

2002-01-29 Thread Jeff 'japhy' Pinyan
On Jan 29, [EMAIL PROTECTED] said: >1- report any objects in File A that are not in File B >2- report any objects that are in File B but not in File A This sounds like the job for two hashes. It also happens to be in the FAQ under the heading "How do I compute the difference of two arrays? How

Re: Comparing files

2002-01-29 Thread Jason Purdy
Feel like I'm back in comp-sci, but this time, they'll actually let me use a real language (don't get me started on "Turing" ;)). I wrote this simple script that should work with 5.003... Jason #!/usr/bin/perl -w # call this with 2 params, such as # > diff.pl [file1] [file2] use strict; m

Re: Comparing files

2002-01-29 Thread charles
If you are just looking to see if X from file one is in file two, and vice versa, you may want to look at p147 in the Cookbook. It's example is comparing the hash keys of two seperate hashes. If you place each line of your file into a hash and the other file in another hash, and compare the to