Search

J

Jimmy

I have two files in a tmp directorie. each file have some data in
them. Some data are the same. I want to search in the files (with file
handles), and display the data on screen. But if they have the same
data in both files, display the data once. Here's my code but doesn't
work. Not all the data is display:

while( <FILEHANDLE> or <FILEHANDLETWO>)
{
$mesAlertes = <FILEHANDLE>;
$mesAlertesDeux = <FILEHANDLETWO>;
$final = ($mesAlertes, $mesAlertesDeux); #take data in both
#but display once if the
data
#is the two files...

print $final;
}

What's wrong???
 
A

Anno Siegel

Jimmy said:
I have two files in a tmp directorie. each file have some data in
them. Some data are the same. I want to search in the files (with file
handles), and display the data on screen. But if they have the same
data in both files, display the data once. Here's my code but doesn't
work. Not all the data is display:

while( <FILEHANDLE> or <FILEHANDLETWO>)

This reads a line from each file and discards them.
{
$mesAlertes = <FILEHANDLE>;
$mesAlertesDeux = <FILEHANDLETWO>;

These read one more line from each file.
$final = ($mesAlertes, $mesAlertesDeux); #take data in both

This sets $final to $mesAlerts and discards $mesAlertsDeux. What
do you want to achieve?
#but display once if the
data
#is the two files...

print $final;
}

What's wrong???

Well, you only work on every other line of each file, that's why you
don't see all the data.

As for discarding data that has already been displayed, your code
doesn't even make an attempt.

In a crude approach, I'd deal with each file on its own. First go
through one file and print it. Also keep the lines you printed in
a hash.

Then print the second file, but skip lines that are in the hash.

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,796
Messages
2,569,645
Members
45,362
Latest member
OrderTrimKetoBoost

Latest Threads

Top