473,324 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Javascript Vs Perl RegExp


Hi all;
I code Perl for CGI, I using regular expression to check the validation

of user input, because the form is small and it run only from my own
computer, anyways if many people using my form, do you think it will be

slow due to Perl is run under server. How about using JavaSCript to
check validation for user input? Do you think it a bit faster?
Thank very much
Phal
Reply

Sep 23 '05 #1
3 2423
phal wrote:

Hi all;
I code Perl for CGI, I using regular expression to check the validation

of user input, because the form is small and it run only from my own
computer, anyways if many people using my form, do you think it will be

slow due to Perl is run under server. How about using JavaSCript to
check validation for user input? Do you think it a bit faster?
Thank very much
Phal
Reply


Hi Phal,

Javascript in general is slow.
I expect regexp from perl are much faster.
You can of course add the regexpr to JS, but you have to validate them again
on the server of course, since it is easy to circumvent JS and make your
own posting to the server.

Regards,
Erwin Moller

Sep 23 '05 #2


phal wrote:
I code Perl for CGI, I using regular expression to check the validation

of user input, because the form is small and it run only from my own
computer, anyways if many people using my form, do you think it will be

slow due to Perl is run under server. How about using JavaSCript to
check validation for user input? Do you think it a bit faster?


If you implement server-side validation first and then add client-side
validtion then yes, for those visiting with browsers with script
enabled/supported the validation does not require the trip back to the
server and initial checks are faster. But don't rely on client-side
validation and give up on the server-side validation.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 23 '05 #3
"phal" <be*******@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...

Hi all;
I code Perl for CGI, I using regular expression to check the validation

of user input, because the form is small and it run only from my own
computer, anyways if many people using my form, do you think it will be

slow due to Perl is run under server. How about using JavaSCript to
check validation for user input? Do you think it a bit faster?


I assume you mean "slow" because of the request, not the general speed of
the check, right?

On equal footing JavaScript will almost always be slower than PERL -
JavaScript carries a lot of baggage and is not as optimized for RegEx's as
Perl is. However in practice Perl runs on the server and is doing many more
tasks while the client is sitting spinning it's wheels - so JavaScript seems
much faster (it has a whole machine sitting there to do this little script
while the server might be doing dozens, or hundreds of requests at the same
time).

So - purely from a performance standpoint - JavaScript may be "faster". You
may eliminate a server request and provide the interface "instant feedback"
(although remember that you'll be delivering more script to the client which
slows things down some).

However it's not safer. Script can be disabled - which would eliminate your
checking completely. Since it runs on the client-side it can also be
modified to return incorrect results. In general you should consider
validations at every level of your application:

1) Client-side (JavaScript) validations improve the user experience but do
not protect the application. These are optional, but can greatly improve
the usability of your application.

2) Server-side (Perl, ColdFusion, ASP, etc) validations protect the
application from "bad" data. These prevent common attacks (SQL injection,
cross-site scripting) and prevent your application from failing due to bad
data (out of range numbers and dates for example). These are not optional
because no other layer of validation is assured to run. In other words the
application must protect itself because it can't trust anything else to do
it.

3) Persistence-layer (Database, LDAP, etc) validation protect the system
from storing "bad" data and allowing it to accumulate. This is needed to
protect your permanent information storage - there are few things so
damaging to a company than to discover that their data is corrupt. Many
people ignore this and say "the application will do it" but this is a
mistake: data has a way of getting around. Your application may very well
not be the only thing accessing the data - another application may need it
for example or somebody may use some provided management tool (SQL Server
Enterprise Manager for example). The data system should therefore protect
itself as much as possible.

Sorry for the lecture... but this stuff is commonly misunderstood. It's
best to get started on the right track in the first place than try to
retrofit things later.

Jim Davis

Sep 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mark | last post by:
I am creating a search engine that will scan pages on my Web site. I do not want any false-positive hits, being defined as any match that does not appear on the page using a Web browser. I am...
3
by: jgarrard | last post by:
Hi, I have an array of strings which are regular expressions in the PERL syntax (ie / / delimeters). I wish to create a RegExp in order to do some useful work, but am stuck for a way of...
10
by: John Passaniti | last post by:
(Note: This is not the same message I posted a week or so ago. The problem that prevented my previous attempt to work was a silly error in the template system I was using. This is a problem...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.