For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2006 > Worse than just a beginner









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Worse than just a beginner
Brian

2006-10-30, 7:03 pm

I'm wondering if someone can do me an enormous favour and write a cgi
for me please, I just can't get my head around the books I have, they
might just as well be written in Klingon.

I would like to be able to enter a number into a form. (eg 1234)
This number would also be output to result.html which I will get to in a
minute.

So, taking the input (x), it needs to be compared against a fixed sum
(z). (eg z = 25)
If x is greater than z, then value z needs to keep being subtracted
until equal to or less than z. (but not less than 1)
(if input is a 6 digit number, another sum, say 2000, can be included to
calc a bit faster than subtracting 25 over and over)

I have a string of numbers or letters that is z (25) in length,
presently in a text file, but there is no reason why this string can't
reside in the script as it will never change.
The end result of comparing x to z = 9, so 9th char in string z is to
be picked up.
I wish to print using if statements so that I could have slight
differences in the html of result.html to count for the 25 different
possibilities of z.
The original input needs to be reflected in any instance of result.html.
Hopefully without any of the code being viewable with the exception of
the html code.

I know it's a big ask, but I would really appreciate it.
Thanks
Brian
Paul Lalli

2006-10-30, 7:03 pm

Brian wrote:
> I'm wondering if someone can do me an enormous favour and write a cgi
> for me please,


While it's possible that someone might do this for you out of sheer
boredom, I personally find that an unlikely result. This list is
generally for helping people learn to use Perl, not to have people
write Perl scripts for them.

You are more likely to get a better response from jobs.perl.org

Paul Lalli

Omega -1911

2006-10-30, 7:03 pm

On 10/24/06, Brian <brian54321uk@yahoo.co.uk> wrote:
> I'm wondering if someone can do me an enormous favour and write a cgi
> for me please, I just can't get my head around the books I have,


Sounds like a homework assignment...
Brian

2006-10-30, 7:03 pm

Omega -1911 wrote:

> On 10/24/06, Brian <brian54321uk@yahoo.co.uk> wrote:
>
>
>
> Sounds like a homework assignment...
>

Not at all , and just for the record, I am 50 years old.
Brian

Charles K. Clarkson

2006-10-30, 7:03 pm

Brian <mailto:brian54321uk@yahoo.co.uk> wrote:

: I'm wondering if someone can do me an enormous favour and
: write a cgi for me please, I just can't get my head around
: the books I have, they might just as well be written in
: Klingon.

You want us to feed you for a day?

Think about what needs to be done. What are the steps
needed to perform the actions to get the results you want?
Here's an example.

1. Get numerical user input.
2. Divide input from step 1 by 25 and keep the remainder.
3. Use the result from step 2 as an index into a string.
4. ...


Notice that my algorithm does not contain elements of a
specific solution. These steps could equally apply to VB, C#,
Java or Perl.

Once you have listed all the steps needed to describe the
problem then you can apply a specific solution. Look at each
step and solve only that step. Solutions are a lot easier if
you break them down into more manageable pieces first.

BTW, You don't have to solve them in the order they will
be used. Solve the easiest one first, then the next and so
on.

Look at step 2 above. Repeated subtractions gets you a
remainder. Now you have a solution for the remaining value.
Try to solve the rest yourself. Come back here when you get
stuck solving a step.

print 1 % 25, "\n";
print 30 % 25, "\n";
print 300 % 25, "\n";
print 1234 % 25, "\n";
print 600000001 % 25, "\n";



HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
Free Market Advocate
Web Programmer

254 968-8328

http://www.clarksonenergyhomes.com/

Don't tread on my bandwidth. Trim your posts.

usenet@DavidFilmer.com

2006-10-30, 7:03 pm

Brian wrote:
> [subject] Worse than just a beginner


Hmmm. I pondered that subject line for a moment. I asked myself, "what
does 'worse than just a beginner' mean?"

A 'beginner' is someone who is just starting to learn. I suppose that
'worse than a beginner' is somebody who does not even begin to learn.

> ... and write a cgi for me


Um hm.

--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)

DJ Stunks

2006-10-30, 7:03 pm


usenet@DavidFilmer.com wrote:
> Brian wrote:
>
> Hmmm. I pondered that subject line for a moment. I asked myself, "what
> does 'worse than just a beginner' mean?"
>
> A 'beginner' is someone who is just starting to learn. I suppose that
> 'worse than a beginner' is somebody who does not even begin to learn.
>
>
> Um hm.


haha well done David :)

-jp

Gav Ford

2006-10-30, 7:03 pm

Brian wrote:
> I'm wondering if someone can do me an enormous favour and write a cgi
> for me please, I just can't get my head around the books I have, they
> might just as well be written in Klingon.
>
> I would like to be able to enter a number into a form. (eg 1234)
> This number would also be output to result.html which I will get to in
> a minute.


To read a value from a CGI form you need to use the module CGI, you can
add it to your program like this:


use CGI qw(:standard);


With this in place you can read the values, for example if the entry box
on the form is called "number" you read it using this:

$number = param ('number);


Now you have that in place, you can set your page up to display the
number entry box
if there is no number or the results if there is one:



#!/usr/bin/perl

use CGI qw(:standard);
$number = param ('number);

if ($number ne undef) {

#code for calculating the result

}
else {

#code for the html form.

}



Hope this helps you to get started.

-Gav



TeeBown

2006-10-30, 7:03 pm



Brian wrote:

> I'm wondering if someone can do me an enormous favour and write a cgi
> for me please, I just can't get my head around the books I have, they
> might just as well be written in Klingon.
>
> I would like to be able to enter a number into a form. (eg 1234)
> This number would also be output to result.html which I will get to in
> a minute.
>
> So, taking the input (x), it needs to be compared against a fixed sum
> (z). (eg z = 25)
> If x is greater than z, then value z needs to keep being subtracted
> until equal to or less than z. (but not less than 1)
> (if input is a 6 digit number, another sum, say 2000, can be included
> to calc a bit faster than subtracting 25 over and over)
>
> I have a string of numbers or letters that is z (25) in length,
> presently in a text file, but there is no reason why this string can't
> reside in the script as it will never change.
> The end result of comparing x to z = 9, so 9th char in string z is to
> be picked up.
> I wish to print using if statements so that I could have slight
> differences in the html of result.html to count for the 25 different
> possibilities of z.
> The original input needs to be reflected in any instance of result.html.
> Hopefully without any of the code being viewable with the exception of
> the html code.
>
> I know it's a big ask, but I would really appreciate it.
> Thanks
> Brian
>


You're right... It's a big ask!
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com