I need to update a perl program that prints
a hyperlink to an autocad drawing. The link will be
based on a truck number that the user enters into an
html page. That page then posts their entries to
this perl script.
This page (cadsearch.cgi) uses another perl page (find_dir_all.pl)
that returns a directory to search based on the truck number.
The issue that I am having is that I know only
the first part of the directory to search due to
inconsistent file naming habits. The first part of the
directory will be returned to this program.
I need to be able to search for a directory that
matches the first part of the directory name.
Example:
Joe User searches for truck number 12345.
I know that the directory will be something like:
BID.12345 Wanna B. Company
or
Quote.12345 Gonna Geta Truck
I know everything up to the end of the number and
it will be a unique directory, but I will not know
what the customer name added to the end will be.
How can I perform a search on a directory by using only
the first part of the directory name?
Below is the code that I must update, trimmed down for this posting:
#!/usr/bin/perl
##!/opt/gnu/bin/perl
#/usr/local/bin/apache/cgi-bin/cadsearch.cgi
#push(@INC,"/cgi-bin");
require "cgi-lib.pl";
use File::Find;
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use Socket;
&ReadParse(*input);
$truck=$input{"truckno"}; #ex: 12345
$searchtype=$input{"searchtype"}; #ex: bid
$dir=`/filesystem/scripts/find_dir_all.pl $truck $searchtype`;
@dir=("$dir/$truck");
$file=$input{"filename"};
#set variable for new dwg convert web app
$dwgpdf="http://webserver/dwgbpdf/";
#variable for hyperlink
$hlink
# finddepth function to locate directory
for ($i=0;$i<=$#dir;$i++){
finddepth(\&dwgWanted,$dir[$i]);
}
# wanted sub to locate files
sub dwgWanted{
$hlink="$File::Find::name" if (/^$file.*$ext2.*/ );
print $hlink
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.