#!/usr/bin/perl -w use strict; my ($title,$actors,$genre,$languages); my (%h,%colours,@a); my $file = "books.txt"; chdir "$ENV{HOME}/forSale" or die "chir: $!\n"; open BOOKS, "<$file" or die "open: $file: $!\n"; print <Books for sale.

Feel free to come and browse, no obligation. All Books are in excellent condition. Offers welcome.


EOH while ( ) { chomp; next if m%^#%; $h{$_}++; } foreach ( sort keys %h ) { @a = split(';',$_); $a[1] = $a[1] ? $a[1] : ' '; if ( $a[2] ) { $a[2] =~ s% %%g; -f $a[2] or die "$a[2]: Not found\n"; $a[0] = "" . $a[0] . ""; } print < EOT } print "
Title Price
$a[0] $a[1]
\n";