#!/usr/bin/perl -w use strict; use Cwd; use File::Find; use File::Path; use Getopt::Long; # header column never has any info... # certainly not now I've deleted it (DL) ((my $progname = $0) =~ s/^.*\///ig); # basename $0 my $warnings; # set this if we have non fatal problems # my $cvsdirectories = ':'; # this gets filled with directories that should have # cvsignores generated in a later pass # Parse options my $no_verbose_progress = 0; my $usage = 0; GetOptions('quiet' => \$no_verbose_progress, # be quiet 'help' => \$usage # help! ); # Print usage if ($usage) { usage(); } unless ($ARGV[0]) { print STDERR "Specify a CSV file name as the program's argument (e.g. CAVETAB2.CSV)\n\n"; usage(); } # One day this may be proofed against this problem, # but another command line parameter (location of expoweb) # is inevitable, and unappealing ($_ = cwd()) =~ s/^.*\///ig; if ($_ ne "noinfo") { print STDERR "This program expects to be run from a CWD of noinfo!\n\n"; usage(); } open (CSV, "< $ARGV[0]") or print STDERR "That filename could not be opened. Exiting.\n" and die $!; open (LENGTHS, "< lengths.dat") or print STDERR "No length data available! Exiting.\n" and die $!; open (LOGFILE, "> make-indxal4.log") or print STDERR "Could not create log file! Exiting.\n" and die $!; my %lhash = munge_lengths(); # Go down a directory chdir ".."; open INDXAL, "> indxal.htm" or die $!; print INDXAL << "END"; Loser Plateau area : Cave description index

Kataster Gruppe 1623:
Loser Augst-Eck - INDEX

Note that information on caves in the adjacent area 1626 (Rauher - Schönberg) is to be found elsewhere. See also the list of lengths and depths for the caves where we have survey data.

END ; # starting to read in csv file, eat header line # Read in pos file to @pos now rather than later so we don't repeat it n times open INPUT2, "< noinfo/all.pos" or print STDERR "Could not find all.pos in the noinfo directory\n" and die $!; my @pos = ; close INPUT2; # While loop which reads in each line of csv file while () { chomp; do_this_line($_); } # Finish writing index file print INDXAL << "END";

END close INDXAL; #print "Information: Making area indices\n"; #make_indices(); print "Information: Done"; if ($warnings) { print " (with warnings)" } unless ($no_verbose_progress) { print ". Run with -q to see what problems occurred."; } print "\n"; # Process a line of the CSV file # First argument is contents of line to process # 2nd arg is the Kataster number of the cave an entrance belongs to (optional) # 3rd arg is the Other number of the cave an entrance belongs to (optional) # 4th arg is the basename of the cave an entrance belongs to (optional) # Returns nothing sub do_this_line { # Split single line into all the fields my ($kat_num, $kat_status, $ents, $other_number, $mult_ents, $file, $linkfile, undef, $name, $unofficial_name, $comment, $area, $explorers, $u_description, $equipment, $qmlist, $katstatus, $references, $u_centre_line, $u_drawn_survey, $survex_file, $length, $depth, $extent, $notes, $ent_name, $tag_punkt, $other_punkt, $desc_other_punkt, $exact_punkt, $fix_type, $gpspresa, $gpspostsa, $northing, $easting, $altitude, $bearings, $map, $location, $approach, $ent_desc, $ent_photo, $marking, $marking_comment, $findability, $findability_comment) = &parse_csv($_[0]); my $parents_name; # If we have been called to process an entrance, we may have been given the cave's Kataster number or Other number if ($_[1] and ! $kat_num) { $kat_num = $_[1]; } if ($_[2] and ! $other_number) { $other_number = $_[2]; } if ($_[3]) { $parents_name = $_[3]; } # Bitch if a link file has too much information. if ($linkfile && $file) { print STDERR "Warning: both a file ($file) and a linkfile ($linkfile) specified. This makes no sense.\n\n"; $warnings = 1; } if ($linkfile && ($kat_status || $name || $unofficial_name || $comment || $area || $explorers || $u_description || $equipment || $qmlist || $katstatus || $references || $u_centre_line || $u_drawn_survey || $survex_file || $length || $depth || $extent || $notes || $ent_name || $tag_punkt || $other_punkt || $desc_other_punkt || $exact_punkt || $fix_type || $gpspresa || $gpspostsa || $northing || $easting || $altitude || $bearings || $map || $location || $approach || $ent_desc || $ent_photo || ($marking and $marking ne "\r" and $marking ne "\r\n" and $marking ne "\n"))) { print STDERR "Warning: In the link cave $kat_num($ents) -> $other_number there is extraneous information provided that will not be used. Please merge it into the description of the cave to which it links. The only information allowed in a link file is Kataster Number,\nEntrances, Other Number, Multiple Entrances, and the name of the linkfile\n\n"; $warnings = 1; } # Generate $linkid which will be kataster no., or other no. if no kataster no. present. Per HTML4 (and XHTML etc.) ID and NAME tokens must begin with alpha characters - hence "id" prepend my $linkid = "id$kat_num"; my $other_number_no_brackets = $other_number; if ($kat_num and $other_number) { $other_number = "($other_number)"; # wrap it in brackets, so it doesn't appear to be official } elsif ($other_number and ! $kat_num) { $linkid = "id$other_number"; } # Under XHTML 1.0, link ids must not have '(', '?', ' ', or '/' $linkid =~ s/\//-/g; $linkid =~ s/\?/q/; $linkid =~ s/\(/:/; $linkid =~ s/\)/:/; $linkid =~ s/ /_/; $linkid = lc($linkid); my $dslen = ($lhash{$linkid}[0] or ""); my $dsdepth = ($lhash{$linkid}[1] or ""); my $dsext = ($lhash{$linkid}[2] or ""); if ($dslen ne "") { $dslen = $dslen."m" }; if ($dsdepth ne "") { $dsdepth = $dsdepth."m" }; if ($dsext ne "") { $dsext = $dsext."m" }; if ($dslen and $length) { $dslen = "$dslen ($length)";}; if ($dsdepth and $depth) { $dsdepth = "$dsdepth ($depth)";}; if ($dsext and $extent) { $dsext = "$dsext ($extent)";}; if ($dslen eq "") { $dslen = $length }; if ($dsdepth eq "") { $dsdepth = $depth }; if ($dsext eq "") { $dsext = $extent }; # Determine the number of directories deep the cave's main page is, in order to link to area descriptions and indxal my $toroot = 'Q'; # hey; it's magic my $counter = ($file =~ tr/\///); while ($counter) { $toroot = join('', $toroot, "/.."); $counter--; } $toroot =~ s/Q\///; # If it's not an entrance, and it's not in 1626, insert it in the index file if ($mult_ents !~ /entrance/ && $area ne 1626) { my $e = $ents; $e =~ s/ +/ /g; print INDXAL "$kat_num $other_number"; if ($e) { print INDXAL " - $e"; } print INDXAL ""; if ($file) { print INDXAL ""; } elsif ($linkfile) { print INDXAL ""; } if ($name) { print INDXAL $name; } else { print INDXAL "?"; } if ($unofficial_name) { print INDXAL " ($unofficial_name)"; } if ($file or $linkfile) { print INDXAL ""; } if ($comment) { print INDXAL " - $comment"; } print INDXAL "\n"; } # If the cave does not have a filename allocated, but does have multiple entrances, keep going through the CSV file until we are at the last entrance, before we return. This could go wrong if we ever did a linkfile for an entire cave (not just an entrance), which possessed multiple entrances. Until we do it stays like this unless ($file) { # this IS necessary if ($mult_ents eq "yes") { die "Umm, this code hasn't been tested recently and may be wrong (specifically using the file snarfer without assigning the return). Comment this death out to see what happens"; my $e_mult_ents; do { ; chomp; my $emult_ents = (&parse_csv($_))[4]; $e_mult_ents = $emult_ents; } while ($e_mult_ents ne "last entrance"); } return; } # If command line option is set, then be quiet unless ($no_verbose_progress) { print "Progress: $file\n"; } # Determine $file's basename and dirname (my $fn = $file) =~ s/^.*\///ig; my $path = $file; $path =~ s/\/$fn//g; # Make the directory that the file is in, in case it doesn't exist yet #mkpath($path); # this is considered harmful now creation of directories is versioned - DL # Open the file and start writing to it open FILE, "> $file" or die $!; print LOGFILE "Created $file\n"; print FILE << "END"; END if ($kat_num) { if ($area ne 1626) { print FILE "1623:$kat_num"; } else { print FILE "<title>1626:$kat_num"; } } else { print FILE "<title>$other_number"; } print FILE << "END"; END print FILE "\n"; print FILE "\n
"; if ($kat_num) {print FILE "$kat_num"} else {print FILE "$other_number"} if ($ents) { print FILE " - $ents" } if ($other_number && $kat_num) { print FILE "
$other_number" } print FILE "
$name"; if ($unofficial_name) { if ($name) { print FILE "
"; } print FILE " ($unofficial_name)"; } print FILE "
$kat_status
"; # if no $kat_status, no problem if ($dslen or $dsdepth or $dsext) { print FILE "\n\n

"; } if ($dslen) { print FILE "Length: ${dslen} "; } if ($dsdepth) { print FILE "Depth: ${dsdepth} "; } if ($dsext) { print FILE "Extent: ${dsext} "; } if ($dslen or $dsdepth or $dsext) { print FILE "

"; } # Entrance specific bit unless ($mult_ents eq "yes") { # If there is only one entrance, print FILE "\n\n

"; if ($tag_punkt || $other_punkt || $exact_punkt || $gpspostsa || $gpspresa || $easting || $northing || $altitude || $fix_type || $desc_other_punkt && !$ent_name) { # basically, if do_ent is going to do anything, print "Entrance:" print FILE "Entrance: "; } # Process the location data for the entrance do_ent($tag_punkt,$other_punkt,$exact_punkt,$gpspostsa,$gpspresa,$easting,$northing,$altitude,$ent_name,$fix_type,$desc_other_punkt); print FILE "

" } else { # If there are multiple entrances multi_ents($file, $kat_num, $other_number, $other_number_no_brackets, $toroot); } # Cave general bit if ($area) { print FILE "\n\n

Nominal area: "; foreach $_ (split(/ /, $area)) { # deal with caves allocated multiple areas if (expandarea($_, 0)) { # drop junk words in $area such as "or" print FILE "$_ - ", (expandarea($_, 0))[0], "        "; # this sucketh mightily. How can I get a horizontal tab? FIXME } } print FILE "

"; } if ($location) { print FILE "\n\n

Location: $location

"; } if ($bearings) { print FILE "\n\n

Bearings: $bearings

"; } if ($approach) { print FILE "\n\n

Approach: $approach

"; } if ($map) { print FILE "\n\n

Map: $map

"; } if ($ent_desc) { print FILE "\n\n

Entrance Description: $ent_desc

"; } if ($ent_photo) { print FILE "\n\n

Entrance Photo: $ent_photo

"; } if($marking or $marking_comment) { print FILE "\n\n

Marking: " } if ($marking) { print FILE "$marking"; } if ($marking and $marking_comment) { print FILE ". (" } if ($marking_comment) { print FILE "$marking_comment" } if ($marking and $marking_comment) { print FILE ")" } if ($marking or $marking_comment) { print FILE "

" } if ($references) { print FILE "\n\n

References: $references

"; } if ($u_description) { print FILE "\n\n

Underground Description: $u_description

"; } if ($equipment) { print FILE "\n\n

Equipment: $equipment

"; } if ($qmlist) { print FILE "\n\n

QM list: $qmlist

"; } if ($u_drawn_survey) { print FILE "\n\n

Survey: $u_drawn_survey

"; } if ($notes) { print FILE "\n\n

Notes: $notes

"; } if ($explorers) { print FILE "\n\n

Explorers: $explorers

"; } if ($katstatus) { print FILE "\n\n

Kataster Status: $katstatus

"; } if ($u_centre_line) { print FILE "\n\n

Centre Line: $u_centre_line

"; } if ($survex_file) { print FILE "\n\n

Survex file: $survex_file

"; } print FILE "\n\n\n
END if (tell(FILE) > 15000) { print STDERR "Warning: File $file is bigger than 15kb; consider splitting its contents up\n\n"; } close FILE; } # Parse a line of CSV data # Argument is the line of data to be processed # Returns array of the separated variables sub parse_csv { my $line = $_[0]; my @parsedline = (); my $field = ''; while ($line =~ m{ \G(?:^|,) (?: "((?> [^"]*) (?> "" [^"]*)*)" | ([^",]*)) }gx) { if ($2) { $field = $2; } elsif ($1) { $field = $1; $field =~ s/""/"/g; } else { $field = ''; } push(@parsedline, $field); } return(@parsedline); } # Find the entrance information, from the entrance the link points at # 1st arg - the filename (as in the CSV) to which the link goes # 2nd arg - the entrance of the cave to which the link goes # Returns nothing sub do_link_ent { my $linkfile = $_[0]; my $linkent = $_[1]; my $linkname = $_[2]; my $storedoffset; $storedoffset = tell(CSV); seek(CSV, 0, 0); while () { chomp; if (grep(/,\"$linkfile\",/, $_)) { if ((&parse_csv($_))[5] eq $linkfile) { if ((&parse_csv($_))[4] eq "yes") { while ((&parse_csv($_))[2] ne $linkent) { $_ = ; chomp; if ((&parse_csv($_))[4] eq "last entrance" && (&parse_csv($_))[2] ne $linkent) { print STDERR "Warning: Link entrance for $linkname not found\n\n"; $warnings = 1; seek(CSV, $storedoffset, 0); return; } } } my (undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, $lent_name, $ltag_punkt, $lother_punkt, $ldesc_other_punkt, $lexact_punkt, $lfix_type, $lgpspresa, $lgpspostsa, $lnorthing, $leasting, $laltitude, undef, undef, undef, undef, undef, undef, $lmarking) = &parse_csv($_); do_ent($ltag_punkt,$lother_punkt,$lexact_punkt,$lgpspostsa,$lgpspresa,$leasting,$lnorthing,$laltitude,$lent_name,$lfix_type,$ldesc_other_punkt, $lmarking); seek(CSV, $storedoffset, 0); return; } } } } # Process the location data for the entrance # Returns nothing sub do_ent { my $punkt; my $calc_easting; my $calc_northing; my $calc_altitude; my $desc; my $tag_punkt = $_[0]; my $other_punkt = $_[1]; my $exact_punkt = $_[2]; my $gpspostsa = $_[3]; my $gpspresa = $_[4]; my $easting = $_[5]; my $northing = $_[6]; my $altitude = $_[7]; my $ent_name = $_[8]; my $fix_type = $_[9]; my $desc_other_punkt = $_[10]; my $marking = $_[11]; # Write out info for entrance if ($ent_name) { print FILE "Entrance Name: $ent_name "; } if ($altitude) { print FILE "Recorded Alt: $altitude "; } if ($northing) { print FILE "Recorded as N$northing "; } if ($easting) { print FILE "Recorded as E$easting "; } if ($fix_type) { print FILE "Fix type: $fix_type "; } if ($tag_punkt) { print FILE "Tag point: $tag_punkt "; } if ($other_punkt) { print FILE "Point: $other_punkt "; if ($desc_other_punkt) { print FILE "Point description: $desc_other_punkt "; } else { print FILE "Point description: none "; } } if ($exact_punkt) { print FILE "Exact entrance: $exact_punkt "; } if ($gpspresa) { print FILE "GPS pre sa: $gpspresa "; } if ($gpspostsa) { print FILE "GPS post sa: $gpspostsa "; } # Decide which punkt to lookup if ($tag_punkt) { $punkt=$tag_punkt; $desc = "tag point"; } elsif ($other_punkt) { $punkt = $other_punkt; $desc = "point"; } elsif ($exact_punkt) { $punkt = $exact_punkt; $desc = "exact point"; } elsif ($gpspostsa) { $punkt = $gpspostsa; $desc = "GPS (post SA)"; } elsif ($gpspresa) { $punkt = $gpspresa; $desc = "GPS (pre SA)"; } # Find the position of that punkt if ($punkt) { for my $surveypoint (@pos) { if ($surveypoint =~ m/\( *([0-9\.\-]*), *([0-9\.\-]*), *([0-9\.\-]*) \) $punkt(\r\n|\n|\r)/){ $calc_easting=$1; $calc_northing=$2; $calc_altitude=$3; } } if ($calc_easting) { print FILE "
\nLookup values for $desc data: "; print FILE "Alt: $calc_altitude "; print FILE "N$calc_northing "; print FILE "E$calc_easting "; } else { print STDERR "Warning: Lookup point for $desc data not found: $punkt\n\n"; $warnings = 1; } } if ($marking) { print FILE "Marking: $marking " }; } # Handle multiple entrances # 1st arg is the file name of the cave to which the entrance belongs # 2nd arg is the Kataster number of the cave # 3rd arg is the Other number of the cave (which may have been put in brackets) # 4th arg is the Other number of the cave without any brackets # 5th arg is the path to return to the root from the cave sub multi_ents { my $file = $_[0]; my $kat_num = $_[1]; my $other_number = $_[2]; my $other_number_no_brackets = $_[3]; my $toroot = $_[4]; print FILE "\n\n

Entrances:

\n\n
    "; my $e_mult_ents; # Process each entrance do { my $e = ; chomp($e); my ($ekat_num, undef, $eents, $eother_number, $emult_ents, $efile, $elinkfile, $elinkent, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, $eent_name, $etag_punkt, $eother_punkt, $edesc_other_punkt, $eexact_punkt, $efix_type, $egpspresa, $egpspostsa, $enorthing, $eeasting, $ealtitude, undef, undef, undef, undef, undef, undef, $emarking) = &parse_csv($e); if ($eother_number) { $eother_number = "($eother_number)"; # wrap it in brackets, so it doesn't appear to be official } print FILE "\n
  • "; if ($elinkfile) { # this is a link to another cave - add link to entrance into cave file but don't generate another file for the entrance print FILE "$eents $eother_number "; do_this_line($e, $kat_num, $other_number_no_brackets); # Process the location data for the entrance do_link_ent($elinkfile, $elinkent, join('', $ekat_num, $eents)); } elsif ($efile) { # call ourselves recursively to create a file for the entrance print FILE "$eents $eother_number "; close FILE; # perl filehandles are not recursively safe (when hacking at 4 in the morning). thus do this. do_this_line($e, $kat_num, $other_number_no_brackets, (($_ = $file) =~ s/^.*\///ig) && $_); open FILE, ">> $file" or die $!; # Process the location data for the entrance do_ent($etag_punkt,$eother_punkt,$eexact_punkt,$egpspostsa,$egpspresa,$eeasting,$enorthing,$ealtitude,$eent_name,$efix_type,$edesc_other_punkt, $emarking); } else { # no entrance file needed, and no link to another cave print FILE "$eents $eother_number"; # Process the location data for the entrance do_ent($etag_punkt,$eother_punkt,$eexact_punkt,$egpspostsa,$egpspresa,$eeasting,$enorthing,$ealtitude,$eent_name,$efix_type,$edesc_other_punkt, $emarking); } print FILE "
  • "; $e_mult_ents = $emult_ents; } while ($e_mult_ents ne "last entrance"); print FILE "\n
"; } # Return detailed area name when handed area code # 1st arg - area code # 2nd arg - generalise subareas sub expandarea { if ($_[1] == 1 && $_[0] =~ /1[a-z]/ && $_[0] ne 1626) { return ("Plateau", "plateau"); } if ($_[1] == 0 && $_[0] eq "1a") { return ("Nearer plateau (access from Top Camp)", "plateau"); } if ($_[1] == 0 && $_[0] eq "1b") { return ("Western plateau (Puffball area)", "plateau"); } if ($_[1] == 0 && $_[0] eq "1c") { return ("Eastern plateau area near Steinbrücken path", "plateau"); } if ($_[1] == 0 && $_[0] eq "1d") { return ("Further plateau near Eislufthöhle", "plateau"); } if ($_[1] == 1 && $_[0] =~ /2[a-z]/ && $_[0] ne 1626) { return ("Schwarzmooskogel ridge", "smkridge"); } if ($_[1] == 0 && $_[0] eq "2a") { return ("Southern Schwarzmooskogel ridge – Stellerweg / Weiße Warze area", "smkridge"); } if ($_[1] == 0 && $_[0] eq "2b") { return ("South-east slopes of Vorderer Schwarzmooskogel – Eishöhle area", "smkridge"); } if ($_[1] == 0 && $_[0] eq "2c") { return ("Vorderer to Hinterer Schwarzmooskogel – Kaninchenhöhle area", "smkridge"); } if ($_[1] == 0 && $_[0] eq "2d") { return ("Northern Schwarzmooskogel ridge (access from Steinbrücken)", "smkridge"); } if ($_[0] eq 3) { return ("Bräuning Alm", "br-alm"); } if ($_[0] eq 4) { return ("Kratzer valley", "kratzer"); } if ($_[0] eq 5) { return ("Schwarzmoos-Wildensee", "wilden"); } if ($_[0] eq 6) { return ("Far plateau", "remote"); } if ($_[0] eq 7) { return ("Egglgrube", "egglgrub"); } if ($_[1] == 1 && $_[0] =~ /8[a-z]/) { return ("Loser/Augst See", "loser"); } if ($_[1] == 0 && $_[0] eq "8a") { return ("South face of Loser - reached from Loser Hütte path", "loser"); } if ($_[1] == 0 && $_[0] eq "8b") { return ("Ammerich and Höllgraben - below Dimmelwand and the last part of toll road", "loser"); } if ($_[1] == 0 && $_[0] eq "8c") { return ("Around Augst See", "loser"); } if ($_[1] == 0 && $_[0] eq "8d") { return ("Loser - Hochanger ridge area", "loser"); } if ($_[0] eq 9) { return ("Gschwandt", "gschwand"); } if ($_[0] eq 10) { return ("N & NE shore of Altauseer See", "aaussee"); } if ($_[0] eq 11) { return ("Augstbach", "augstb"); } if ($_[0] eq 1626) { return ("1626 (Rauher - Schönberg)", "1626"); } } # Usage sub usage { print << "EOF"; USAGE: $progname [-options] -q, --quiet Be quiet about progress -h, --help Show this message $progname must be run from noinfo directory of expoweb hierarchy. EOF exit(0); } # Parent function for making per area tables from CAVETAB2, which may then be included in some fashion # Returns nothing sub make_indices { make_table(1, "1a", "plateau", "Around Top Camp and below Bräuning Wall"); make_table(0, "1b", "plateau", ""Nearer" plateau - including holes found on "geologists' walk"", "Note that this area probably overlaps the last one - I found 171 whilst looking for 190 (as B9)..."); make_table(0, "1c", "plateau", ""Nearer" plateau northeast of the col"); make_table(0, "1d", "plateau", ""Middle" plateau"); make_table(1, "2a", "smkridge", "Caves known or expected to link into the Stellerweg - Eishöhle and Kaninchenhöhle systems"); make_table(0, "2b", "smkridge", "Caves in the same area - but not yet linked"); make_table(1, "3", "br-alm"); make_table(1, "4", "kratzer"); make_table(1, "5", "wilden"); make_table(1, "6", "remote"); make_table(1, "7", "egglgrub"); make_table(1, "8a", "loser", "South face of Loser - reached from Loser Hütte path"); make_table(0, "8b", "loser", "Ammerich and Höllgraben - below Dimmelwand and the last part of toll road"); make_table(0, "8c", "loser", "Around Augst See"); make_table(0, "8d", "loser", "Loser - Hochanger ridge area"); make_table(1, "9", "gschwand"); make_table(1, "10", "aaussee"); make_table(1, "11", "augstb"); make_table(1, "1626", "1626"); } # Output the blurb for the index table # 1st argument specifies whether to overwrite output file # 2nd argument specifies area id # 3rd argument specifies area directory # 4rd argument (optional) gives a title to the table # 5th argument (optional) specifies a comment to the table # Returns nothing sub make_table { my @caves; my $i = 0; if ($_[0] == 1) { open TAB, "> $_[2]/index.html.table" or die $!; } else { open TAB, ">> $_[2]/index.html.table" or die $!; } @caves = area_grep("$_[1]"); if ($_[3]) { print TAB "

$_[3]

\n"; } if ($_[4]) { print TAB "

$_[4]

\n"; } print TAB "\n"; while ($caves[$i][0]) { print TAB "\n"; $i++; } print TAB "
$caves[$i][1]$caves[$i][3]
\n\n"; close TAB; } # Goes through CSV, looking in area column for the area id passed to it in the first argument # Returns array, 1 x 1st dimension per matching area, 4 x 2nd dimension for linkid, number, file link, and name sub area_grep { my $givenarea = $_[0]; my @return; seek(CSV,0,0); while () { chomp; my ($kat_num, undef, undef, $other_number, undef, $file, $linkfile, undef, $name, undef, undef, $area) = &parse_csv($_); if ($area eq $givenarea) { my $linkid = "id$kat_num"; my $number = $kat_num; my $link = $file; if ($other_number) { if ($kat_num) { $number = "$kat_num ($other_number)"; } else { $linkid = "id$other_number"; $number = $other_number; } } if ($linkfile && ! $file) { $link = $linkfile; } # Sanitise linkid $linkid =~ s/\//-/g; $linkid =~ s/\?/q/; $linkid =~ s/\(/:/; $linkid =~ s/\)/:/; $linkid =~ s/ /_/; $linkid = lc($linkid); push(@return, [$linkid, $number, $link, $name]); } } return(@return); } sub munge_lengths { print "Munging lengths\n"; my %return; while () { chomp; my ($id, $len, $depth, $ext) = split("\t", $_); $return{"id".lc($id)} = [$len, $depth, $ext]; } return (%return); }