would anyone like to fix up this script for me so that it will sort through the SERVER.RND and return the results, I am entirely in newbie land, sorry.

#!/usr/bin/perl -- &getformdata; print "Content-type: text/html\n\n"; print "<center><h2>Request Data</h2><p>\n"; if ($FORM{todolist} eq '') {print " <form action=$ENV{REQUEST_URI} method=post> <table> <tr><td>Job Number:</td><td><input name=jobnumber size=20></td></tr> <tr><td>Phone Number:</td><td><input name=phonenumber size=20></td></tr> </table> <input type=hidden name=todolist value=search> <input type=submit value=Search></form>\n"; } elsif ($FORM{todolist} eq 'search') { print "searching<p>\n"; &loaddata; sub loaddata { $datafilename = 'webserver.rnd'; open(DATAFILE, $datafilename) or print "Can't open data"; @data = <DATAFILE>; close(DATAFILE); while(<DATAFILE>) { if(length<101) { # 1 more for newline chomp; warn "Record '$_' too short, skipping"; next; } push @jobNumbers, substr $_,0,6; push @customerNames, substr $_,6,10; push @telephoneNumbers, substr $_,16,10; push @agencyReferences, substr $_,26,10; # adjust either start or end if you need to skip spaces push @statusDescriptions, substr $_,36,64; } } { print "searching<p>\n"; &loaddata; $found = 0; foreach $entry (@data) { ($a, $b, $c, $d) = split(/:/, $entry); if ($a eq $FORM{jobnumber}) { if ($b eq $FORM{phonenumber}) { print "$d <br>\n"; $found = 1; } } } if ($found == 0) {print "no matches found<br>\n";} } sub getformdata { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/<!--(.|\n)*-->//g; $value =~ s/<([^>]|\n)*>//g; $FORM{$name} = $value; } }

-----------------------------

This is a random file,
with the extension .RND, and named SERVER.RND.

Each record is exactly 100 bytes long,
makes it easier to calculate.

The fields are as follows:
01-06 JOB NUMBER
07-16 CUSTOMER NAME
17-26 TELEPHONE NUMBER
27-36 AGENCY REFERENCE
37-100 STATUS DESCRIPTION (60 BYTES + 4 BYTES SPACES)


CUSTOMERS
Customer enters Job Number and Telephone Number.
If both match, return the
record showing the Job Number and Status Description.

AGENCIES
Agency enters the Agency Reference.
Return all records that match that
agency, showing Job Number and Status Description.

2002-07-16 Edit by Corion - added CODE tags


In reply to help fix script? by jdawes

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.