develooper Front page | perl.beginners | Postings from February 2002

Re: accessing a windows directory

Thread Previous | Thread Next
From:
Eric Peers
Date:
February 27, 2002 09:15
Subject:
Re: accessing a windows directory
Message ID:
000501c1bfb2$54a79fc0$0c82940a@usa.int
My problem is when the $search variable is used in the search_file
subroutine. The code works fine if I change Active Logos 600 dpi to
Active_Logos_600_dpi.

I don't recall which perl book this code began life as, but here it is:

#! /usr/bin/perl -w

use strict;
use CGI qw(:standard);
use File::Basename;

my $dir = "D:\\Inetpub\\wwwroot\\kfvstart\\intranet\\Eric\\Logos\\Active
Logos 600 dpi\\";
my $criteria;
my $search;
my $files;
my $counter = '0';

print header;
print start_html (-title=>'Logo Search',
                  -bgcolor=>'#ffffff');

if(param('criteria') ) {
    search_file();
} else {
    display_menu();
}
print end_html;
sub search_file {
    $criteria = param('criteria');
    $search = $dir . $criteria;
 print "<center>";
    print "<h1>Search Results</h1>";
 print '<font face="Arial" size="3">';
 print '<table cellpadding="3" cellspacing="3" border="1">';
    while ($files = <$search*>) {
  $counter++;
        $files =~ s#.*/##; #remove part before last slash
        my ($name, $directory, $extension) = fileparse($files,'\..*');
        my $filename = $name . $extension;
  my $uri = "http://wv1svlg001/Active%20Logos%20600%20dpi/" . $filename;
  if ($counter % 2) {
   print '<tr bgcolor="#e8e8e8"><td nowrap>';
     } else {
   print '<tr><td nowrap>';
  }
        print "<a href=$uri>$filename</a><br>";
  print '</td></tr>';
    }
 print '</table cellpadding="3" cellspacing="3" border="0">';
    my $home = "http://wvweb/Eric/imagesearch.pl";
    print "<p><table><tr><td>";
    print "<a href=$home>Search Again</a></font><br>\n";
 print "</td></tr></table></center>";
}

sub display_menu {
    print start_form,
        b,('Search for logo '),
  p,
  p,('Enter Customer Number:'),
  p,
        textfield(-name=>'criteria'),
        p,
        submit(-name=>'Search'),
        end_form;
}

Any suggestions for improvement will be appreciated.

Thanks,

Eric





Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About