2008/05/16

The Labs.Com Issue_07_PerlScript
Last update 1999/02/20

TPJ: Issue_07_PerlScript

This is a collection of programs published by The Perl Journal. You can download all source-code also from TPJ: Programs.
  1. greetings
  2. commas
  3. button
  4. More Samples on PerlScript
Issue_07_PerlScript
1. greetings
Download greetings

 <html> 
 <head> 
 <title>A Simple PerlScript Greeting</title> 
 <script language="PerlScript"> 
  
 sub ShowGreeting { 
     $window->document->write( "Greetings, Perl Hacker!<br>\ 
  "); 
 } 
  
 </script> 
 </head> 
 <body> 
 <script> 
 ShowGreeting(); 
 </script> 
 <p> 
 This message generated with a PerlScript subroutine. 
 <p> 
 </body> 
 </html> 

Issue_07_PerlScript
2. commas

Download commas

 <head> 
 <title>Commas PerlScript Style</title> 
 <script language="PerlScript"> 
 sub commas { 
     local($_) = @_; 
     1 while s/(.*\d)(\d\d\d)/$1,$2/; 
     $_; 
 } 
 sub doCommas_onClick() { 
     $x = $AddComma->floatIn->{'Value'}; 
     $result = commas($x); 
     $result = "\$".$result; 
     $AddComma->floatOut->{'Value'} = $result; 
 } 
  
 </script> 
 </head> 

Issue_07_PerlScript
3. button

Download button

 <HTML> 
 <HEAD> 
 <TITLE>A Simple PerlScript Case Convertor</TITLE> 
 <SCRIPT language="PerlScript"> 
  
 sub Sample::toUpper_onClick() { 
     $input = $Sample->TheString->{'Value'}; 
     $input =~ tr/[a-z]/[A-Z]/; 
     $Sample->Converted->{'Value'} = $input; 
 } 
  
 sub Sample::toLower_onClick() { 
     $input = $Sample->TheString->{'Value'}; 
     $input =~ tr/[A-Z]/[a-z]/; 
     $Sample->Converted->{'Value'} = $input; 
 } 
  
 sub Sample::obfuscate_onClick() { 
     $input = $Sample->TheString->{'Value'}; 
     $output = join("", reverse split(/(\S+)/,$input)); 
     $Sample->Converted->{'Value'} = $output; 
 } 
  
 </SCRIPT> 
 </HEAD> 
 <BODY> 
 <center> 
 <h2>PerlScript in Action</h2> 
 <hr> 
 <form action="" name="Sample"> 
 <input type="text"  size="70" name="TheString"> 
 <p> 
 <input type="button" name = "toUpper" value="Upper Case Conversion"\ 
 > 
 <input type="button" name = "toLower" value="Lower Case Conversion"\ 
 > 
 <input type="button" name = "obfuscate" value="Obfuscation"> 
 <p> 
 <input type="text" size="80" name="Converted"> 
 </form> 
 </center> 
 </BODY> 
 </HTML> 

Issue_07_PerlScript
4. More Samples on PerlScript

  • Issue_07_PerlScript

                                                                                                                                   

Last update 1999/02/20

All Rights Reserved - (C) 1997 - 2008 by The Labs.Com

Top of Page

The Labs.Com