Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Comparing unordered but similar data files

by Kanji (Parson)
on Sep 23, 2010 at 00:37 UTC ( #861413=note: print w/replies, xml ) Need Help??

in reply to Comparing unordered but similar data files

Your use of eq is actually comparing the number of elements in each array, which is why you only see a failure if one file has more lines than the other.

If you're using Perl 5.10 or newer, you can achieve what you want using ~~ (the smart match operator) instead:-

if (@sorted ~~ @sorted2) {

If you're using Perl 5.8 or older, you'll need to compare the arrays element by element, an example of which you can find in perlfaq4 - How do I test whether two arrays or hashes are equal?.


Replies are listed 'Best First'.
Re^2: Comparing unordered but similar data files
by gwam (Initiate) on Sep 23, 2010 at 07:05 UTC
    Thanks alot Kanji! That done the trick. I figured it was something like that. I thought i was going to need a foreach loop to access and compare each element in the arrays. awesome that Perl has that smart match operator. Thanks again you saved me alot of time.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2021-10-24 01:24 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (88 votes). Check out past polls.