Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Calling Diff on Arrays

Reply
Thread Tools

Calling Diff on Arrays

 
 
Robert Love
Guest
Posts: n/a
 
      08-29-2005
I can read in two text files into arrays of lines, manipulate and sort
the contents. I then want to pass the arrays to diff and manipulate and
print the results of the diff. I have it working using temporary files
that I write the arrays into. My question is how do I do this directly,
without writing to temporary files?

What I have now looks like:

@results = `diff tmp1 tmp2`;

I have read FAQ 4.xx and that is NOT what I want. All tips & advice
appreciated.
 
Reply With Quote
 
 
 
 
rlove@mac.com
Guest
Posts: n/a
 
      08-29-2005

Kevin Michael Vail wrote:
> In article <(E-Mail Removed)>,
> Robert Love <(E-Mail Removed)> wrote:
>
> > I can read in two text files into arrays of lines, manipulate and sort
> > the contents. I then want to pass the arrays to diff and manipulate and
> > print the results of the diff. I have it working using temporary files
> > that I write the arrays into. My question is how do I do this directly,
> > without writing to temporary files?
> >
> > What I have now looks like:
> >
> > @results = `diff tmp1 tmp2`;
> >
> > I have read FAQ 4.xx and that is NOT what I want. All tips & advice
> > appreciated.

>
> Algorithm:iff


Thanks but that doesn't seem to be part of my perl installation. I'm
working on a set of RH 7.2 linux machines that I don't adminster. I
can't talk the pointy hair bosses into upgrading either.

Just installing this local to my machine wouldn't help others I want to
run the tool.

So, I repeat the question. Is there a way to call diff directly
without writing the contents of my @rrays to files first?

 
Reply With Quote
 
 
 
 
A. Sinan Unur
Guest
Posts: n/a
 
      08-29-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote in
news:(E-Mail Removed) oups.com:

>
> Kevin Michael Vail wrote:
>> In article <(E-Mail Removed)>,
>> Robert Love <(E-Mail Removed)> wrote:
>>
>> > I can read in two text files into arrays of lines, manipulate and
>> > sort the contents. I then want to pass the arrays to diff and
>> > manipulate and print the results of the diff. I have it working
>> > using temporary files that I write the arrays into. My question is
>> > how do I do this directly, without writing to temporary files?
>> >
>> > What I have now looks like:
>> >
>> > @results = `diff tmp1 tmp2`;
>> >
>> > I have read FAQ 4.xx and that is NOT what I want. All tips &
>> > advice appreciated.

>>
>> Algorithm:iff

>
> Thanks but that doesn't seem to be part of my perl installation. I'm
> working on a set of RH 7.2 linux machines that I don't adminster. I
> can't talk the pointy hair bosses into upgrading either.
>
> Just installing this local to my machine wouldn't help others I want
> to run the tool.


perldoc -q lib

If the machines are identical, all you have to do is to install in a
subdirectory to which you have access, and then add the appropriate

use lib 'path to my lib';

statement to your script, then copy to other machines.

> So, I repeat the question. Is there a way to call diff directly
> without writing the contents of my @rrays to files first?


It probably depends on the diff program you are using. Reading man diff
on my Cygwin system points out a possible solution:

FILES are `FILE1 FILE2' or `DIR1 DIR2' or `DIR FILE...' or
`FILE... DIR'. If --from-file or --to-file is given, there are no
restrictions on FILES. If a FILE is `-', read standard input. Exit
status is 0 if inputs are the same, 1 if different, 2 if trouble.

Sinan

--
A. Sinan Unur <(E-Mail Removed)>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/cl...uidelines.html
 
Reply With Quote
 
James E Keenan
Guest
Posts: n/a
 
      08-30-2005
Robert Love wrote:
> I can read in two text files into arrays of lines, manipulate and sort
> the contents. I then want to pass the arrays to diff and manipulate and
> print the results of the diff. I have it working using temporary files
> that I write the arrays into. My question is how do I do this directly,
> without writing to temporary files?
>


You state that you "manipulate" the contents in the temp files and then
"manipulate" the arrays. My hunch is that the solution depends on what
you mean by "manipulate" in each context. Algorithm:iff, as others
have suggested, may be of use here. For determining the differences
between two or more sets, my CPAN distribution List::Compare may be useful.

jimk
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multidimensional arrays and arrays of arrays Philipp Java 21 01-20-2009 08:33 AM
Diff CSS styles for diff INPUT TYPE='s? A Traveler ASP .Net 6 08-31-2004 09:17 PM
[ANN] Diff::LCS 1.1.0, Diff::LCS 1.0.4 Austin Ziegler Ruby 3 08-09-2004 06:34 AM
diff Process under diff users Cyril Vi?ville Perl 1 06-29-2004 06:22 PM
Same sessionID retuned to diff browsers in diff machines Berrucho ASP .Net 2 12-05-2003 02:23 PM



Advertisments