perl script help

bc bc99 at pacbell.net
Sat Oct 30 11:07:28 CDT 1999



Help -  I am looking for someone that can write a perl script.

The requirements are:  Perl1.pl calls perl2.pl with username and
password.
Perl2.pl returns  the record of data for username and associate field
names by
finding the matching username/password record in the file.
Then in Per1.pl, display the record with the field names on a web page
(i.e. fullname = jack smith, address=1464 w street ave )
note: the special character in the record must stay in the record in the
return trip.
Perl1.pl  has a  'require ossd.cfg'  line.
Perl2.pl  has a  'require  ospd.cfg' line.
ossd.cfg and ospd.cfg  have the same variables in them and obviously
the  content
is different.
 What's the format of the file ?  | delimited ascii file
  the perl1.pl is cgi. It is getting the username/password from web form

   and display the result on a web page.
   perl2.pl  is not cgi. It get input from maybe stdin; find the data in
the
file; output maybe stdout. perl2.pl is a like a blackbox.

If you are interested, please email me ,Betty Chung at bc99 at pacbell.com
and give me
some idea of the cost and time needed.


This is my attempt:
It does not work because  the shell trys to interpret the data in the
record on the return trip.
  I do not know how to prevent this.

#perl1.pl
#!/usr/local/bin/perl

$search_field="username";
$search_for="alan";
$pa = "perl perl2.pl search_for=$search_for |";
$co=0;
open (LIST_OF_FILES, $pa);
while ($filename = <LIST_OF_FILES>){
@out = $filename;
#print "processing ",$filename;
$out[$co] = $filename;
$co = $co+1;
open (MY_FILE_HANDLE, $filename);
while (<MY_FILE_HANDLE>) {
   process information in line of file by using ,$_
}
}

print $out[0];


($fieldn,$fieldc) = split(/\n/, $out[0]);
print "$fieldn\n";
print "$fieldc\n";

print $fieldns[2];
print $fieldnc[2];

print "test\n";
-------------------------------------------------------------------
#perl2.pl
#!/usr/bin/perl

use CGI qw (:standard);
use CGI::Carp qw(fatalsToBrowser);

 $search_field="username";
 $config="ossd.cfg";
unless(require $config){
  $config="database.cfg";
}

$q = new CGI;
  $search_for = $q->param(search_for);

$f = join("~", @fields);

&search_database($search_for);

$ff = $results[0];

 print $ff;

exit;

sub search_database{

  my $search_for = $_[0];
  open(DB, $database) or die "Error opening file: $!\n";
    while(<DB>){
      if($search_field =~ /all/i){
        if(/$search_for/oi){push @results, $_};
      } else {
        ($key, at field_vals) = split(/\|/, $_);
        if($field_vals[$search_field] eq $search_for){push @results,
$_};
      } # End of else.
    } # End of while.
  close (DB);

 } # End of search_database subroutine.





More information about the Nyc-perl-jobs-pm mailing list