#!/usr/bin/perl print "Content-type:text/html\n\n"; print < Test

Check How it work


Serial Number:

Part Number:

Quantity:

Extra Opt:

 

EndOfHTML print " \n"; #### #!/usr/bin/perl print "Content-type:text/html\n\n"; use Time::Local; $today = timelocal(localtime); $now = &unix_to_date($today); sub unix_to_date { # -------------------------------------------------------- # Returns the date in the format "mm-dd-yyyy". # Warning: If you change the default format, you must also modify the &date_to_unix # subroutine below which converts your date format into a unix time in seconds for sorting purposes. my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(time()); ($day < 10) and ($day = "0$day"); $mon += 1; ($mon < 10) and ($mon = "0$mon"); $year += 1900; return "$mon\/$day\/$year"; } $datafile = "default.db"; 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/~!/ ~!/g; $FORM{$name} = $value; } open(OUTF,">>default.db") or dienice("Couldn't open default.db for writing: $!"); # This locks the file so no other CGI can write to it at the # same time... flock(OUTF,2); # Reset the file pointer to the end of the file, in case # someone wrote to it while we waited for the lock... seek(OUTF,0,2); print OUTF "$now|$FORM{'serialnumber'}|$FORM{'partnumber'}|$FORM{'quantity'}|$FORM{'DIMMOpt'}|\n"; close(OUTF); print <New record has been added !

New record has been added today $now !


Thanks !!
EndHTML sub dienice { my($msg) = @_; print "

Error

\n"; print $msg; exit; } 3. getpart.pl This is a perl script from someone, it take serial number and give me part number and it pulled from a website. Example: $getpart 1234ABCD I will get the result is $501-1234-01 #### #!/usr/bin/perl -w $numArgs = $#ARGV + 1; if ($numArgs == 1) { $INPUT = "$ARGV[0]"; } else { exit; } use LWP::Simple; $page = get("http://from/this/SfcStatus?sfcnumber=${INPUT}&tested=DONTCARE"); #print $page ($plain_text = $page) =~ s/<[^>]*>//gs; @item=split(' ',$plain_text); #$count = 0; #foreach $i (@item) { # print "$count : $i\n"; # $count += 1; # } #exit; # First, find Shop Order, MFG Center, and Status foreach $i ( 30...60) { # print " $i $item[$i]\n"; if ( $item[$i] eq 'ORDER' ) { $SHOP = $item[ $i + 1 ]; if ( length $SHOP < 8 ) { $SHOP .= "\t"; } } elsif ( $item[$i] eq 'CENTER' ) { $MFG_CENTER = $item[ $i + 1 ]; if ( length $MFG_CENTER < 8 ) { $MFG_CENTER .= "\t"; } } elsif ( $item[$i] eq 'GROUP' ) { $ITEMGROUP = $item[ $i + 1 ]; } elsif ( $item[$i] eq 'STATUS' ) { $STATUS = $item[ $i + 1 ]; if ( length $STATUS < 8 ) { $STATUS .= "\t"; } last; } } # KEY: Part Number Serial Number Shop Order MFG CENTER STATUS if ( $item[60] eq 'DEKIT' ) { print "$item[34]\n"; } elsif ( $item[27] eq 'SHIP' && $item[60] ne 'DEKIT' ) { print "$item[34]\n"; } else { print "$item[26]\n"; }