in reply to searching a file, results into an array
Several ways of doing it:
($filename, $title) = split /\t/;or
($filename, $title) = /^(.*)\t(.*)$/;assuming $_ contains each line of the file in turn.
No reason to be scared of hashes. In your example it's no more difficult to use a hash, than pushing onto separate arrays. In fact I think its easier. Having found your filename and title:
$docTitles{$filename} = $title;having declared my %docTitles; first, of course :-)
Then you can create your HTML by doing something like:
print "<table>\n"; for my $doc (sort keys %docTitles) { print "<tr><td>$doc</td><td>$docTitles{$doc}</td></tr>\n"; } print "</table>\n";
(or whatever your markup is gonna look like)
|
|---|