steve silvers wrote:

I have no idea how to do this. I have tens of thousands of lines in a text file that houses numbers for internal purposes. There are usually 20 on a line, with a range of (01 - 80).

Example:

my @data = (
'08|10|13|16|19|22|28|32|33|37|41|46|47|50|51|52|53|55|71|76',
'06|11|16|19|20|29|31|35|39|44|50|57|58|59|60|62|71|72|76|77',
'03|05|06|08|09|10|11|16|17|28|31|41|42|43|45|46|56|61|69|79',
'05|07|12|13|15|16|17|19|21|25|41|45|47|48|53|58|63|69|76|79',
'01|02|04|07|08|12|17|19|25|27|29|34|38|44|47|60|62|64|73|75',
'01|04|06|07|08|09|11|13|14|19|25|26|37|39|41|60|61|62|63|80',
'04|07|09|17|19|27|28|29|39|41|46|51|52|54|57|58|60|68|74|80'
);

foreach (@data) {
split(/|/,$_)
# Here is where I need to run "I think a hash" to tell me the two, three, four, five, numbers that appear on each line out of the above 7 lines. As an example;


say I only have two lines in my text file.

01|02|03|04|05
01|03|05|33|36

The output needs to say that the above found 01,03,05 in the two sets of numbers.
Does this make sense? I'm sure this is pretty easy for someone who know hashes real good.


}

[8<'d]

for (@data){
for (split /\|/){
$unique{$_}++ unless exists $unique{$_}
}}

print join ', ',  map{sprintf "%02d",$_}sort {$a <=> $b} keys %unique;

HTH

-- mike higgins
#!/usr/bin/perl
my @data = (
'08|10|13|16|19|22|28|32|33|37|41|46|47|50|51|52|53|55|71|76',
'06|11|16|19|20|29|31|35|39|44|50|57|58|59|60|62|71|72|76|77',
'03|05|06|08|09|10|11|16|17|28|31|41|42|43|45|46|56|61|69|79',
'05|07|12|13|15|16|17|19|21|25|41|45|47|48|53|58|63|69|76|79',
'01|02|04|07|08|12|17|19|25|27|29|34|38|44|47|60|62|64|73|75',
'01|04|06|07|08|09|11|13|14|19|25|26|37|39|41|60|61|62|63|80',
'04|07|09|17|19|27|28|29|39|41|46|51|52|54|57|58|60|68|74|80'
);

for (@data){
for (split /\|/){
$unique{$_}++ unless exists $unique{$_}
}}

print join ', ',  map{sprintf "%02d",$_}sort {$a <=> $b} keys %unique;

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to