The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Querying, Constructing, and Transforming XML with XQuery iBot Oracle Updates (RSS) 0 04-06-2008 06:10 AM
Help Required In Transforming A File anju Shell Programming and Scripting 3 01-15-2008 02:47 AM
transforming a multiline record to single line anju Shell Programming and Scripting 9 01-14-2008 07:55 AM
javascript injection fed.linuxgossip Shell Programming and Scripting 20 08-21-2007 07:46 AM
javascript onClick help k@ssidy UNIX for Dummies Questions & Answers 1 10-12-2005 09:18 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-29-2008
marringi marringi is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 36
transforming small javascript into perl

Quote:
<script type="text/javascript">
var param="$function"
if (param=="yes")
{
document.write("open")
}
else
{
document.write("closed")
}
</script>
I need to transform this small javascript into a perl. So then when I need to use it I can call $something, instead of using this javascript.

Could someone help me archive this?
  #2 (permalink)  
Old 04-29-2008
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
Why do you think Javascript can be rewritten into Perl? Javascript is executed by the client side (browser) while Perl code is executed at the server side. You can use Perl to generate Javascript (because that is just text) on the server side, but that is not using Perl to replace Javascript because they serve totally different purposes.
  #3 (permalink)  
Old 04-29-2008
marringi marringi is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 36
Ok, I see.
Is it not possible to create

if something print this
else print this?

The thing is that I am having a problem with old browser reading the javascript that I am executing from the cgi program.
  #4 (permalink)  
Old 04-29-2008
marringi marringi is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 36
I see that this will be a bigger problem then I that, so I will figure a
way around this problem.

Thanks anyway
  #5 (permalink)  
Old 04-29-2008
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
Then that is a client-side Javascript problem. It has nothing to do with Perl even though Perl is used to generate the Javascript.

If what you want to do is to execute different bits of Javascript depending on condition. That is possible with Javascript alone. People are doing that all over the Web to address different browsers. Sometimes you may need to wrap the code in a try ... catch block to catch exceptions so that you can try several variations until finding one that works!

Of course, unless you have reasons to generate dynamic Javascript from Perl, moving all the javascript away from the HTML to a separate .js file that is sourced from the HTML esp. if you have lots of javascript. Then you can serve that JS file with Apache directly rather than wasting resources generating JS from Perl.
  #6 (permalink)  
Old 04-30-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Looks like this thread has now migrated to if and else
  #7 (permalink)  
Old 04-30-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Correction; that other thread was closed by the moderator as a duplicate of this one.

Comment #2 in the other thread has some sort of answer (I hope).

Last edited by era; 04-30-2008 at 02:39 PM..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:57 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0