Here is something q&d (quick & dirty) that can be a start and can probably
be done more elegantly.
Scott

while (<DATA>) {
     chomp;                   # eliminate \n
     ($v1,$v2) = split /\,/;       #get variables
     next unless ($_);        #skip blank lines
     $hash{$v1}++;            # incr ctr
     print "\n$v1-",$hash{$v1},",$v2"; #print results
}

__DATA__
LT00430,31

LT00432,32

LT00504,33

LT00504,34

LT00518,35

LT00532,36

LT00533,37

LT00533,38

LT302,39

LT302,40

LT320,41

LT347,42

LT350,43

LT350,44

LT355,45

LT359,46

LT360,47

LT360,48

LT362,49


                                                                                       
                                        
                    "Greg Wardawy"                                                     
                                        
                    <[EMAIL PROTECTED]>                      To:     
<[EMAIL PROTECTED]>           
                    Sent by:                                     cc:                   
                                        
                    [EMAIL PROTECTED]        Subject:     hash key 
with a regexp                           
                    eState.com                                                         
                                        
                                                                                       
                                        
                                                                                       
                                        
                    02/20/01 03:21 PM                                                  
                                        
                                                                                       
                                        
                                                                                       
                                        


Hello all,

Is it correct to say:

print if $var1 == $hash{$key =~ /$var2\d+/};

or:

print if $var1 == $hash{$key\d+};

if I need a conditional print for all keys of the hash which starts with
$var2?

The reason I'm asking is that I have a comma separated list:

LT00430,31

LT00432,32

LT00504,33

LT00504,34

LT00518,35

LT00532,36

LT00533,37

LT00533,38

LT302,39

LT302,40

LT320,41

LT347,42

LT350,43

LT350,44

LT355,45

LT359,46

LT360,47

LT360,48

LT362,49

and I'm thinking about renaming the duplicates (somehow - I don't know how
yet) to get the following list:

LT00430,31

LT00432,32

LT005041,33

LT005042,34

LT00518,35

LT00532,36

LT005331,37

LT005332,38

LT3021,39

LT3022,40

LT3203,41

LT347,42

LT3501,43

LT3502,44

LT355,45

LT359,46

LT3601,47

LT3602,48

LT362,49

so I would be able to build a hash with a unique keys and use it to print
the data I need. Does this make sense or am I doing something wrong?



TIA



Greg





_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users




_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to