- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Change diff-Algorithmus
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-19-2006 09:05 PM
тАО01-19-2006 09:05 PM
I am using this algorithm to compare two files.
Code:
@one = qw(a a a a b c d e f g);
@two = qw(b c e h i i i i j);
my %tracker = ();
$tracker{$_} .= 1 for @one;
$tracker{$_} .= 2 for @two;
for (sort keys %tracker) {
if ($tracker{$_} !~ /1/) {
print "$_ has been added\n";
} elsif ($tracker{$_} !~ /2/) {
print "$_ has been deleted\n";
} else {
print "$_ is in both old and new\n";
}
}
It has following output:
a has been deleted
b is in both old and new
c is in both old and new
d has been deleted
e is in both old and new
f has been deleted
g has been deleted
h has been added
i has been added
j has been added
here "a" is mentioned only once, since there are 4 "a"-s in the first array. What can I chnage in order to get them all appearing?
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-19-2006 09:24 PM
тАО01-19-2006 09:24 PM
Re: Change diff-Algorithmus
not really a solution, but have you had a look at the "comm" command ?
- Tags:
- comm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-19-2006 09:39 PM
тАО01-19-2006 09:39 PM
Re: Change diff-Algorithmus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-19-2006 09:45 PM
тАО01-19-2006 09:45 PM
Re: Change diff-Algorithmus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-19-2006 10:29 PM
тАО01-19-2006 10:29 PM
Solutionhow about:
@one = qw(a a a a b c d e f g);
@two = qw(b c e h i i i i j);
my %tracker = ();
$tracker{$_} .= 1 for @one;
$tracker{$_} .= 2 for @two;
for (sort keys %tracker) {
$tester = length($tracker{$_});
if ($tracker{$_} !~ /1/) {
print "$_ has been added $tester time(s)\n";
} elsif ($tracker{$_} !~ /2/) {
print "$_ has been deleted $tester time(s)\n";
} else {
print "$_ is in both old and new\n";
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2006 08:20 PM
тАО01-22-2006 08:20 PM
Re: Change diff-Algorithmus
how are you getting on with this?
Can you pleas update.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2006 09:33 PM
тАО01-22-2006 09:33 PM
Re: Change diff-Algorithmus
I was just playing around with this piece of code.
You idea worked for me perfectly. I just put the $tester in a for-loop to print $tester-times the element and now I have it.
Thank you for this idea!