I would appreciate some help with this: I have a field called <%Pages%> which includes a series of numbers separated by commas (ie. 45,567,13,6). I wish to extract each number so as to use them all in a HTML template. I thus wrote a global with my limited perl experience: my global is named <%pages%>
sub {
my $index = shift;
# get field, split into an array
my ($tags) = GT::Template->tags;
my (@pages) = split /,/, $tags->{Pages};
# just to debug: shows I'm extracting correctly!
my $numberpages = @paras;
# initiate loop to output each element of the array
for ($index=0; $index<@pages; $index++) {
return @pages[$index];
}
# end sub
}
In my HTML, I just want to do a simple loop to show each number:
for page=first to page=last
print page <BR>
next
It's the perl that's not correct. I only have the first number returned. But I very much suspect that there is a far more elegant way of achieving my objective! Thanks for some expert advice!
sub {
my $index = shift;
# get field, split into an array
my ($tags) = GT::Template->tags;
my (@pages) = split /,/, $tags->{Pages};
# just to debug: shows I'm extracting correctly!
my $numberpages = @paras;
# initiate loop to output each element of the array
for ($index=0; $index<@pages; $index++) {
return @pages[$index];
}
# end sub
}
In my HTML, I just want to do a simple loop to show each number:
for page=first to page=last
print page <BR>
next
It's the perl that's not correct. I only have the first number returned. But I very much suspect that there is a far more elegant way of achieving my objective! Thanks for some expert advice!