I'm trying to change how data is currently being added to a file to condense it and make it easier to work with.
Below is the code snip that processes and adds the data to the appropriate file. The current Output to the file is what I am trying to change and not having alot of luck.
The desired output to file is at the bottom of this post. Any suggestions or help to accomplish this would be much appreciated. Basically take the current output to file:
IE:
# Subfolder~Keyword
2D-Animals~animals
2D-Animals~bee
2D-Animals~whale
2D-Holidays-St_Patricks_Day~bee
2D-Holidays-St_Patricks_Day~beer
........
and change it so outputted with all Keywords that match the Subfolder are all on one line, like such...
# Subfolder::Keyword1::Keyword2::Keyword3... 2D-Animals::animals::bee::whale 2D-Holidays-St_Patricks_Day::bee::beer
# Sub routine passes the (MainCategory,SubFolder,Keyword) # Sub routine is in a foreach loop here
foreach ..... { add_category($Mcat,$sfolder,$Kword); }
sub add_category { my ($MainCat,$SubCat,$Kwrd) = @_; my $catline = $SubCat . "~" . $Kwrd; my $foundit = 0; my $MKDIR = 0; my $category_file = $maincatlogs . $MainCat . ".catlog"; my $newfolder = $basedir . $MainCat; my $newkwd_line = ''; if (-d $newfolder) { $MKDIR = 1; }
if (-e $category_file) { open(CAT,"<$category_file") or die $!; my @catdata = <CAT>; close(CAT);
LOOP: foreach (@catdata) { chomp $_; if ($_ eq $catline) { $foundit = 1; last LOOP; } }
if (!$foundit) { open(CAT2,">>$category_file") or die $!; print CAT2 "$catline\n"; close(CAT2);
open(CAT2,"<$category_file") or die $!; my @newcat_data = <CAT2>; close(CAT2); my @sortdata = sort( { $a cmp $b } @newcat_data);
open(CAT2,">$category_file") or die $!; print CAT2 @sortdata; close(CAT2); } } else {
open(CAT,">$category_file") or die $!; print CAT "$catline\n"; close(CAT); } # Create a new Category directory to store subcat pages and keyword pages
unless ($MKDIR) {
mkdir("$newfolder", 0777);
chmod 0777, $newfolder;
unless (-w $newfolder) { die("Unable to write to new folder: $newfolder$!"); }
}
return;
}
# Current Output to file ################## # Subfolder~Keyword
2D-Animals~animals 2D-Animals~bee 2D-Animals~whale 2D-Holidays-St_Patricks_Day~bee 2D-Holidays-St_Patricks_Day~beer 2D-Medical~doctor 2D-Objects~alarm 2D-Objects~email 2D-Objects~wine 2D-People-Disabled~golf 2D-People~birthday 2D-People~golf 2D-Sports-Golf~golf 3D-Animals~animals 3D-Food~bee 3D-Food~beer 3D-Holidays-Birthdays~birthday 3D-Holidays-Birthdays~birthdays 3D-Office~email 3D-People~bee 3D-Sports~golf 3D-Text-Spotlight~email Mini-Animals~animals Mini-Animals~bee Mini-Animals~whale Mini-Computers~email Mini-Food~bee Mini-Food~beer Mini-Other~alarm Mini-Sports~golf Mini-Tools~alarm
# Desired output to file ##########################3 # Subfolder::Keyword1::Keyword2::.... etc 2D-Animals::animals::bee::whale 2D-Holidays-St_Patricks_Day::bee::beer 2D-Medical::doctor 2D-Objects::alarm::email::wine 2D-People-Disabled::golf 2D-People::birthday::golf 2D-Sports-Golf::golf 3D-Animals::animals 3D-Food::bee::beer 3D-Holidays-Birthdays::birthday::birthdays 3D-Office::email 3D-People::bee 3D-Sports::golf 3D-Text-Spotlight::email Mini-Animals::animals::bee::whale Mini-Computers::email Mini-Food::bee::beer Mini-Other::alarm Mini-Sports::golf Mini-Tools::alarm
TIA.
Mike<mickalo>Blezien =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing Providing Internet Solutions that work! http://www.thunder-rain.com Web Hosting http://www.justlightening.net Tel: 1(985)902-8484 MSN: [EMAIL PROTECTED] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]