Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^2: Remove node information by searching tag element

by veerubiji (Sexton)
on Nov 23, 2011 at 14:06 UTC ( #939665=note: print w/ replies, xml ) Need Help??

in reply to Re: Remove node information by searching tag element
in thread remove node information by searching tag element.

Actually sorry for not providing full information now I edited so please help me with that. I am not storing in a hash.

Comment on Re^2: Remove node information by searching tag element
Replies are listed 'Best First'.
Re^3: Remove node information by searching tag element
by MidLifeXis (Monsignor) on Nov 23, 2011 at 14:11 UTC

    The basic process is still the same. You record what you have seen and make processing decisions based on that data.

    doSomething($data) unless $seen{$key}++

    Providing appropriate values for $key, doSomething(), and $data are left as an exercise for the reader.

    Update: Perhaps I am misunderstanding your question. Please post what you expect to see as output given the provided input data.


      Sorry still you didn't understand my problem I think, In the above input data as I provided, in that data number tag is same in first data node and third data node, but reaming information is different only number tag is same. I need to delete the entire node if number tag element is same in any node. I am printing $info into new file so before printing into new file I need to eliminate duplicate nodes by using number tag. I hope now you understand clearly, I posted my expected result also. can you suggest me.

        Given your output data, the approach I provided will do the job. $key should be the 'number tag element'. Don't add the results if you have already seen the number.

        This block of code illustrates the technique.

        my @data = qw( a b 3 d a f b ); my %seen; for ( @data ) { print $_, "\n" unless $seen{$_}++; } __DATA__ a b 3 d f

        You should be able to apply this technique to your problem space.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2015-10-09 00:07 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (232 votes), past polls