Am a perl newbie.
when I try displaying this script in a browser, I get this error "Can't cd to : " .
However, this script works in command line.
For now, I would like to display the list of files in a browser.
Also, how do I create a form to search these images with?
thanks
#find.pl
#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use strict;
use CGI;
use warnings;
use Cwd;
use File::Find::Rule;
my $q = new CGI;
my $imageDir = ("/var/my $image;
my @files;
my $files = qr/^\d{6,6}.*\.jpg?$/i;
@files = File::Find::Rule->file
->name($files)
->in($imageDir);
print $q->header();
$q->start_html("Images in $imageDir");
foreach my $image (@files){
if($image){
print <<HTML;
<a href="$image">$image</a>
HTML
}
else{
print <<HTML;
sorry, $image does not exist
HTML
}
}
when I try displaying this script in a browser, I get this error "Can't cd to : " .
However, this script works in command line.
For now, I would like to display the list of files in a browser.
Also, how do I create a form to search these images with?
thanks
#find.pl
#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use strict;
use CGI;
use warnings;
use Cwd;
use File::Find::Rule;
my $q = new CGI;
my $imageDir = ("/var/my $image;
my @files;
my $files = qr/^\d{6,6}.*\.jpg?$/i;
@files = File::Find::Rule->file
->name($files)
->in($imageDir);
print $q->header();
$q->start_html("Images in $imageDir");
foreach my $image (@files){
if($image){
print <<HTML;
<a href="$image">$image</a>
HTML
}
else{
print <<HTML;
sorry, $image does not exist
HTML
}
}