Tutorialspoint

Perl index Function

#!/usr/bin/perl

$string = "That is test";

$index = index ($string, 'is');

print "Position of is in the string $index\n";

Perl hex Function

#!/usr/bin/perl

print hex '0xAf'; # prints '175'
print "\n";
print hex 'aF';   # same

Lua nested if Statement

lua

--[ local variable definition --]
a = 100;
b = 200;

--[ check the boolean condition --]

if( a == 100 )
then
   --[ if condition is true then check the following --]
   if( b == 200 )
   then
      --[ if condition is true then print the following --]
      print("Value of a is 100 and b is 200" );
   end
end

print("Exact value of a is :", a );
print("Exact value of b is :", b );

Perl grep Function

#!/usr/bin/perl

@list = (1,"Test", 0, "foo", 20 );

@has_digit = grep ( /\d/, @list );

print "@has_digit\n";

if else Statement in Lua

lua

--[ local variable definition --]
a = 100;

--[ check the boolean condition --]

if( a < 20 )
then
   --[ if condition is true then print the following --]
   print("a is less than 20" )
else
   --[ if condition is false then print the following --]
   print("a is not less than 20" )
end

print("value of a is :", a)

if Statement in Lua

lua

--[ local variable definition --]
a = 10;

--[ check the boolean condition using if statement --]

if( a < 20 )
then
   --[ if condition is true then print the following --]
   print("a is less than 20" );
end

print("value of a is :", a);

bounce in down effect

<html>
   <head>
   
      <style>
         .animated {
            background-image: url(/css/images/logo.png);
            background-repeat: no-repeat;
            background-position: left top;
            padding-top:95px;
            margin-bottom:60px;
            -webkit-animation-duration: 10s;
            animation-duration: 10s;
            -webkit-animation-fill-mode: both;
            animation-fill-mode: both;
         }
         
         @-webkit-keyframes bounceInDown {
            0% {
               opacity: 0;
               -webkit-transform: translateY(-2000px);
            }
            60% {
               opacity: 1;
               -webkit-transform: translateY(30px);
            }
            80% {
               -webkit-transform: translateY(-10px);
            }
            100% { 
               -webkit-transform: translateY(0);
            }
         }
         
         @keyframes bounceInDown {
            0% {
               opacity: 0;
               transform: translateY(-2000px);
            }
            60% {
               opacity: 1;
               transform: translateY(30px);
            }
            80% {
               transform: translateY(-10px);
            }
            100% {
               transform: translateY(0);
            }
         }
         
         .bounceInDown {
            -webkit-animation-name: bounceInDown;
            animation-name: bounceInDown;
         }
      </style>
      
   </head>
   <body>
   
      <div id = "animated-example" class = "animated bounceInDown"></div>
      <button onclick = "myFunction()">Reload page</button>
      
      <script>
         function myFunction() {
            location.reload();
         }
      </script>
      
   </body>
</html>

Perl goto Function

#!/usr/bin/perl

$count = 0;

START:
$count = $count + 1;

if( $count > 4 ) {
   print "Exiting program\n";
} else {
   print "Count = $count, Jumping to START:\n";
   goto START;
}

bounce in effect

<html>
   <head>
   
      <style>
         .animated { 
            background-image: url(/css/images/logo.png);
            background-repeat: no-repeat;
            background-position: left top;
            padding-top:95px;
            margin-bottom:60px;
            -webkit-animation-duration: 10s;
            animation-duration: 10s; 
            -webkit-animation-fill-mode: both;
            animation-fill-mode: both; 
         }
         
         @-webkit-keyframes bounceIn {
            0% {
               opacity: 0;
               -webkit-transform: scale(.3);
            }
            50% {
               opacity: 1;
               -webkit-transform: scale(1.05);
            }
            70% {
               -webkit-transform: scale(.9);
            }
            100% {
               -webkit-transform: scale(1);
            }
         }
         
         @keyframes bounceIn {
            0% {
               opacity: 0;
               transform: scale(.3);
            }
            50% {
               opacity: 1; 
               transform: scale(1.05);
            }
            70% {
               transform: scale(.9);
            }
            100% {
               transform: scale(1);
            }
         }
         
         .bounceIn {
            -webkit-animation-name: bounceIn; 
            animation-name: bounceIn;
         }
      </style>
      
   </head>
   <body>
   
      <div id = "animated-example" class = "animated bounceIn"></div>
      <button onclick = "myFunction()">Reload page</button>
      
      <script>
         function myFunction() {
            location.reload();
         }
      </script>
      
   </body>
</html>

Perl gmtime Function

#!/usr/bin/perl

@weekday = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");

$local_time = gmtime();

print "Local time = $local_time\n";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
$year = $year + 1900;
print "Formated time = $mday/$mon/$year $hour:$min:$sec $weekday[$wday]\n";

Advertisements
Loading...