Web Analytics Made Easy -
StatCounter array reference - CodingForum


No announcement yet.

array reference

  • Filter
  • Time
  • Show
Clear All
new posts

  • array reference

    I've got an array of a bunch of html pages. What I'd like to do is to create "Next" and "Previous" links for each of these htmls. Therefore, for the first html in the array, I'd like to be able to grab the second html in the array and put that value into the "Next" href of the first html. For the second html, I'd like to grab the first html in the array for the Previous link, and the third html in the array for the Next link, and so on and so on, until I reach the last html, in which case I'll only need to create a Previous link.

    Is this do-able?

  • #2
    I'm not sure if you are embedding some Perl into an HTMl doc or what, but this would work for a simple Perl script:

    my $this_file = "file1.pl"; #change for each file
    @htmldocs = ("file1.pl", "file2.pl", "file3.pl", "file4.pl");
    foreach (0..3) {
    if ($this_file eq $htmldocs[$_]) {
     if ($htmldocs[$_ + 1] ne $null) {
      print qq~<a href="file~ . $_ + 1 . qq~.pl">Next</a> &gt;~;
     if ($htmldocs[$_ - 1] ne $null) {
      print qq~&lt; <a href="file~ . $_ - 1 . qq~.pl">Previous</a>~;
    if ($ENV{'QUERY_STRING'} eq "Afrow UK") {
    print "$ENV{'QUERY_STRING'} rocks!";
    } else {
    print qq~$ENV{'QUERY_STRING'} sucks :)~;