JoshFink
Thu 30th May '02, 11:13am
Thank you for your time, I have a question on Perl and I'd like some help if possible. It's probably really easy for someone who knows perl, but that's not me (right now at least).
I have an ImageFolio script and it allows uploads. It pulls a list of all categories to upload to from a categories.txt file which contains a list of all categories and sub categories.
I would to limit it to a category called "User Uploads" and all that is below it, like below :
User Uploads
--- Josh
------- Christmas 2001
--- Joe
------- Weekend Party
------- Family Photos
------- Nothing Exciting
--- Bill
--- Brian
Here is the snippet of code that checks the category.
################################################## #############################
# GET CATLIST
# We read in the list of all of the categories from the categories.txt file
# which is built by build.pl and create a selection form
################################################## #############################
sub get_catlist {
open (FILE,"$catfile") or &Error("Could not open category index, $catfile. Reason: $!");
my(@LINES)=<FILE>;
@LINES = sort(@LINES);
close(FILE);
chomp @LINES;
$catlist .= qq|<select name="category">|;
foreach $LINE (@LINES) {
$space = "";
($category, $imagecount) = split(/\t/, $LINE);
@categories = split (/\//, $category);
foreach $cat (@categories) {
$space .= "......";
}
$newcategory = pop @categories;
$newcategory =~ s/_/ /g;
$space =~ s/\.\.\.\.\.\.//;
if ($category eq $FORM{'category'}) {
$catlist .= qq|<option value="$category" selected>$space$newcategory|;
}
else {
$catlist .= qq|<option value="$category">$space$newcategory|;
}
}
$catlist .= qq|</select>|;
}
Here is the Categories.txt that it reads:
Birthdays 0
Birthdays/Emma_-_March_11th_2001 22
Birthdays/Taylor_March_10th_2001 12
Christmas_2001 0
Christmas_2001/Christmas_Party_-_December_15th,_2001 37
Christmas_2001/Christmas_Tree_and_Decorations 8
Christmas_2001/Jake_Playing 14
Christmas_2001/Trying_To_Take_Christmas_Pictures 40
Dog_Pictures 0
Dog_Pictures/Amber 7
Dog_Pictures/Huck 9
Dog_Pictures/Jake 0
Dog_Pictures/Jake/10_Weeks_Old 25
Dog_Pictures/Jake/11_Weeks_Old 8
Dog_Pictures/Jake/13_Weeks_Old 35
Dog_Pictures/Jake/Just_Found 55
Dog_Pictures/MISC 25
Dog_Pictures/Riley 3
User_Uploads 0
User_Uploads/Dave_and_Jyothi 2
User_Uploads/Eric_-_Leslie_-_Jackson 0
User_Uploads/Eric_-_Leslie_-_Jackson/May_8th_-_12th_-_2002 21
User_Uploads/Kari 0
Vacation_Pics 0
Vacation_Pics/Josh_and_Lisa_-_Cleveland_-_April_26th_2002 4
Weddings 0
Weddings/Cherry_-_April_27th_2002 263
Weddings/Goldrich_-_May_27th_2001 91
User_Uploads/Hayden_and_Jill 0
Thanks,
Josh
I have an ImageFolio script and it allows uploads. It pulls a list of all categories to upload to from a categories.txt file which contains a list of all categories and sub categories.
I would to limit it to a category called "User Uploads" and all that is below it, like below :
User Uploads
--- Josh
------- Christmas 2001
--- Joe
------- Weekend Party
------- Family Photos
------- Nothing Exciting
--- Bill
--- Brian
Here is the snippet of code that checks the category.
################################################## #############################
# GET CATLIST
# We read in the list of all of the categories from the categories.txt file
# which is built by build.pl and create a selection form
################################################## #############################
sub get_catlist {
open (FILE,"$catfile") or &Error("Could not open category index, $catfile. Reason: $!");
my(@LINES)=<FILE>;
@LINES = sort(@LINES);
close(FILE);
chomp @LINES;
$catlist .= qq|<select name="category">|;
foreach $LINE (@LINES) {
$space = "";
($category, $imagecount) = split(/\t/, $LINE);
@categories = split (/\//, $category);
foreach $cat (@categories) {
$space .= "......";
}
$newcategory = pop @categories;
$newcategory =~ s/_/ /g;
$space =~ s/\.\.\.\.\.\.//;
if ($category eq $FORM{'category'}) {
$catlist .= qq|<option value="$category" selected>$space$newcategory|;
}
else {
$catlist .= qq|<option value="$category">$space$newcategory|;
}
}
$catlist .= qq|</select>|;
}
Here is the Categories.txt that it reads:
Birthdays 0
Birthdays/Emma_-_March_11th_2001 22
Birthdays/Taylor_March_10th_2001 12
Christmas_2001 0
Christmas_2001/Christmas_Party_-_December_15th,_2001 37
Christmas_2001/Christmas_Tree_and_Decorations 8
Christmas_2001/Jake_Playing 14
Christmas_2001/Trying_To_Take_Christmas_Pictures 40
Dog_Pictures 0
Dog_Pictures/Amber 7
Dog_Pictures/Huck 9
Dog_Pictures/Jake 0
Dog_Pictures/Jake/10_Weeks_Old 25
Dog_Pictures/Jake/11_Weeks_Old 8
Dog_Pictures/Jake/13_Weeks_Old 35
Dog_Pictures/Jake/Just_Found 55
Dog_Pictures/MISC 25
Dog_Pictures/Riley 3
User_Uploads 0
User_Uploads/Dave_and_Jyothi 2
User_Uploads/Eric_-_Leslie_-_Jackson 0
User_Uploads/Eric_-_Leslie_-_Jackson/May_8th_-_12th_-_2002 21
User_Uploads/Kari 0
Vacation_Pics 0
Vacation_Pics/Josh_and_Lisa_-_Cleveland_-_April_26th_2002 4
Weddings 0
Weddings/Cherry_-_April_27th_2002 263
Weddings/Goldrich_-_May_27th_2001 91
User_Uploads/Hayden_and_Jill 0
Thanks,
Josh