You haven't given any sample data, but here is an example of how you could do it using the last few lines of your question as the "@words"
The above will print each unique "word", and how many times it appears.#!/usr/bin/perl -w use strict; use Data::Dumper::Simple; my @words = qw(to check now across my string whether any elements in +my string are repeated, and if so, how many times. I've read alot about manipulating arrays, b +ut they're all based on arrays that you create yourself, rather than arra +ys created by opening a textfile, so I'm not sure how to manipulate my ar +ray. Any help would be much appreciated.); my %unique_words; for (@words) { $unique_words{$_}++; } print Dumper(%unique_words);
Cheers,
Darren :)
In reply to Re: Newbie Q:How do I compare items within a string?
by McDarren
in thread Newbie Q:How do I compare items within a string?
by PerlGrrl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |