Gossamer Forum
Home : General : Perl Programming :

[:(]New to perl and cgi. Need HELP

Quote Reply
[:(]New to perl and cgi. Need HELP
Hi all,

I am new to cgi and perl, i have a small script which i wrote in Korn shell programming. I heard cgi and perl is very powerfull but i am not sure they can rewrite what i have in shell programing and can use cgi and perl to work on website or not. can you help me to rewrite it in cgi so i can learn and use it on web?
Thank you very much.
=======================
#!/bin/ksh

#############################################################################
#
# This script will be helpful to us because it will check for
# any bad (part number-serial number) with at least 15 numbers when scanned.
# If the serail number is on the bad SN list it will be written to
# a file called found_fail.txt. If it is not in the bad SN list it will
# write to found_good.txt.
# It also checks for the correct part number and any duplicate part
# number that has been scanned. It compares the SN in a file called scanned.lst.
# We need to edit the part number, so it can check for a correct part number
# while making sure the bad SN list is saved as badsn.txt.
#
#
##############################################################################
while :
do
echo "Enter serial number [0 to quit]: \\c"
read serial
if [ $serial -eq 0 ]
then
break
fi
echo "$serial" | grep "^[0-9]...........[0-9]$" >> /dev/null
if test $? -ne 0
then
echo " !!! ERROR !!! Serial number must be 13 digits long. Please try again."
continue
fi
echo "$serial" | grep 501XXXX >> /dev/null
if test $? -ne 0
then
echo " INVALID serial (must have 501XXXX prefix)! Please try again."
continue
fi
if [ ! -f scanned.lst ]
then
touch scanned.lst
fi
cat scanned.lst | grep $serial >> /dev/null
if test $? -eq 0
then
echo " ALREADY SCANNED - No further action is to be performed."
continue
else
echo $serial >> scanned.lst
fi
cat badsn.txt | grep $serial >> /dev/null
if test $? -eq 0
then
echo " BAD Serial Number found: <$serial>"
echo $serial >> found_fail.txt
continue
else
echo " GOOD Serial Number. OK, pass!"
echo $serial >> found_good.txt
continue
fi
done





Quote Reply
Re: [britneythuyduong] [:(]New to perl and cgi. Need HELP In reply to
Yes, you could rewrite it to work as a Perl CGI. I'd suggest getting some Perl books or searching for 'perl tutorial' on http://www.google.com to get started.


Adrian
Quote Reply
Re: [brewt] [:(]New to perl and cgi. Need HELP In reply to
Hi Adrian,
I can not read a book for a few day to write this script on the web, i will have syntax error Frown, i just bought Perl How to Program yesterday. It take me 3 week or more than a month to study and practice Smile
Would you or someone help me write this so i can help this as an example .

Thanks,
Quote Reply
Re: [britneythuyduong] [:(]New to perl and cgi. Need HELP In reply to
Your best bet would to post this in the Custom Modification Jobs forum and see if anyone will take on the job. You will more than likely need to pay someone to do this for you though.

Regards,
Charlie
Quote Reply
Re: [britneythuyduong] [:(]New to perl and cgi. Need HELP In reply to
>>It take me 3 week or more than a month to study and practice<<

The code you have is very similar to perl already so it shouldn't be too tricky to convert.
Quote Reply
Re: [britneythuyduong] [:(]New to perl and cgi. Need HELP In reply to
If you know how to program (ie. already know how to program in a lanaguage), then Perl shouldn't be too hard to catch on.
First, you learn the basics: variables, conditionals, loops, etc.
Once you've got that down (shouldn't take long), then you can venture on to how to read and write to files, regular expressions, and then
how to use the CGI module (getting input from forms). Okay, maybe that could take a while to digest... but you won't regret doing so.


Adrian
Quote Reply
Re: [brewt] [:(]New to perl and cgi. Need HELP In reply to
In Reply To:
If you know how to program (ie. already know how to program in a lanaguage), then Perl shouldn't be too hard to catch on.

Actually, I tend to find the opposite - Perl offers so many different ways to do the same thing (functional vs. OO, for loops vs. while loops, substr/index vs. regex, etc., etc.) that someone familiar with a much more strict programming language (Java, C, etc.) is going to have some difficulties learning to relax their coding style Wink.

The opposite applies as well - someone used to the flexibility of Perl is going to have trouble switching to a rigid language like Java or C.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [jagerman] [:(]New to perl and cgi. Need HELP In reply to
So does that explain why I find Perl very easy compared to JavaScript? I've been trying to learn JavaScript for years and just can't figure it out. Maybe it's that OO programming being shoved down my throat that I don't care for.

--Philip
Links 2.0 moderator
Quote Reply
Re: [ThatPerson1024] [:(]New to perl and cgi. Need HELP In reply to
Hi all,
Smile I know i have to read Perl book and rewrite this program, i just come here to ask so i can learn from the other Smile, Knowlegde is our power and we can learn from friend is faster than read a book then do it by yourseft Mad Am I right ? Smile
Gentlemen, if you are a Pro with cgi and Perl it only take you less than 30 min Sly, me ?? i just read chapter one Blush
Thank for reading this,