# # List of cols from SQL to group the sessions by. Each additional group added will # become a subgroup of the group above it. # $group[0] = "State"; $group[1] = "City"; my @last_group = (); $path = $session_path; while( $hash = $sth->fetchrow_hashref() ) { for ($i=0; $i{$group[$i]}) { $path = $session_path; for ($j=0; $j<$i+1; $j++) { $path = $path . "\\" . $hash->{$group[$j]}; } mkdir($path); print "$group[$i]: " . $hash->{$group[$i]} . "\n"; }