Hi monks, haven't been on in awhile and haven't posted in an even longer while. Having trouble with a hash slice. Somehow I'm duplicating a slice of data, but have no idea how I'm doing it. Here's the relevant code...
$to = "foo\@bar.com";
$subject = "New CDs now";
$file_name = "AAAAA.txt";
$from = "that\@person.com";
$last_dir = "Spam";
$spam->{$to} = $to;
$spam->{$to}->{$subject} = $subject;
$spam->{$to}->{$subject}->{$file_name} = $file_name;
$spam->{$to}->{$subject}->{$file_name}->{'path'} = $last_dir;
$spam->{$to}->{$subject}->{$file_name}->{'from'} = $from;
$to = "foo2\@bar.com";
$subject = "New CDs now";
$file_name = "BBBBB.txt";
$from = "that2\@person.com";
$last_dir = "Spam";
$spam->{$to} = $to;
$spam->{$to}->{$subject} = $subject;
$spam->{$to}->{$subject}->{$file_name} = $file_name;
$spam->{$to}->{$subject}->{$file_name}->{'path'} = $last_dir;
$spam->{$to}->{$subject}->{$file_name}->{'from'} = $from;
print "\n";
for my $email_slice (sort keys %{$spam}) {
print "email_slice - $email_slice\n";
for my $subject_slice (sort keys %{$email_slice}) {
print "subject_slice - $subject_slice\n";
for my $fn_slice (sort keys %{$subject_slice}) {
print "fn_slice - $fn_slice\n";
}
}
print "\n";
}
Sorry for the sloppy code, however, this comes from a very large script and just to figure this part out I wrote this code into a separate smaller script for debugging.
Most of you should be able to just paste this code into a vi session and run it, nothing special. Here's the output...
email_slice - foo2@bar.com
subject_slice - New CDs now
fn_slice - AAAAA.txt
fn_slice - BBBBB.txt
email_slice - foo@bar.com
subject_slice - New CDs now
fn_slice - AAAAA.txt
fn_slice - BBBBB.txt
Notice how the fn_slice is duplicated? What I'm trying to get is...
email_slice - foo2@bar.com
subject_slice - New CDs now
fn_slice - BBBBB.txt
email_slice - foo@bar.com
subject_slice - New CDs now
fn_slice - AAAAA.txt
Notice how the AAAAA.txt and BBBBB.txt are separated by their respective email addresses? I can not imagine how the fn_slice is getting duplicated? I think it has something to do with the $subject since it's the same, however, the email_slice should take care of that and separate it.
Thank you monks for your help, AGAIN! :)