Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Programming Scripts Articles
Page 2 of 33
How to set all the border bottom properties in one declaration in JavaScript DOM?
To set the border bottom properties in one declaration in JavaScript, use the borderBottom property. It allows you to set the border-bottom-width, border-bottom-style, and border-bottom-color.ExampleYou can try to run the following code to learn how to set border bottom properties − #box { border: 2px dashed blue; width: 120px; height: 120px; } Set border bottom color Demo Text Demo Text function display() { document.getElementById("box").style.borderBottom = "thin dashed #000000"; }
Read MoreHello World using Perl.
Perl is a programming language developed by Larry Wall, specially designed for text processing.Just to give you a little excitement about Perl, I'm going to give you a small conventional Perl Hello World program,You can try it using the Demo link.Example#!/usr/bin/perl # This will print "Hello, World" print "Hello, world";
Read MoreEscaping Characters in Perl
Perl uses the backslash (\) character to escape any type of character that might interfere with our code. Let's take one example where we want to print double quote and $ sign −Example#!/usr/bin/perl $result = "This is "number""; print "$result"; print "\$result";OutputThis will produce the following result −This is "number" $result
Read MoreAccessing Hash Elements in Perl
When accessing individual elements from a hash in Perl, you must prefix the variable with a dollar sign ($) and then append the element key within curly brackets after the name of the variable. For example −Example#!/usr/bin/perl %data = ('John Paul' => 45, 'Lisa' => 30, 'Kumar' => 40); print "$data{'John Paul'}"; print "$data{'Lisa'}"; print "$data{'Kumar'}";OutputThis will produce the following result −45 30 40
Read MoreFormat Date and Time in Perl
You can use localtime() function in Perl to get a list of 9-elements and later you can use the printf() function to format date and time based on your requirements as follows −Example#!/usr/local/bin/perl ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); printf("Time Format - HH:MM:SS"); printf("%02d:%02d:%02d", $hour, $min, $sec);OutputWhen the above code is executed, it produces the following result −Time Format - HH:MM:SS 06:58:52
Read MoreCircular References in Perl
A circular reference in Perl occurs when two references contain a reference to each other. You have to be careful while creating references otherwise a circular reference can lead to memory leaks. Following is an example −Example#!/usr/bin/perl my $foo = 100; $foo = \$foo; print "Value of foo is : ", $$foo, "";OutputWhen the above program is executed, it produces the following result −Value of foo is : REF(0x9aae38)
Read MorePerl First Program
Interactive Mode ProgrammingYou can use Perl interpreter with -e option at the command line, which lets you execute Perl statements from the command line. Let's try something at $ prompt as follows −$perl -e 'print "Hello World"'This execution will produce the following result −Hello, worldScript Mode ProgrammingAssuming you are already on $ prompt, let's open a text file hello.pl using vi or vim editor and put the following lines inside your file.Example#!/usr/bin/perl # This will print "Hello, World" print "Hello, world";Here /usr/bin/perl is actual the Perl interpreter binary. Before you execute your script, be sure to change the mode of ...
Read MoreComments in Perl
Comments in any programming language are friends of developers. Comments can be used to make program user-friendly and they are simply skipped by the interpreter without impacting the core functionality. For example, in the above program, a line starting with hash # is a comment.Simply saying comments in Perl start with a hash symbol and run to the end of the line −# This is a comment in perlLines starting with = are interpreted as the start of a section of embedded documentation (pod), and all subsequent lines until the next =cut are ignored by the compiler. Following is the ...
Read MoreWhitespaces in Perl
A Perl program does not care about whitespaces. Following program works perfectly fine −#!/usr/bin/perl print "Hello, world";But if spaces are inside the quoted strings, then they would be printed as is. For example −Example#!/usr/bin/perl # This would print with a line break in the middle print "Hello world";OutputThis will produce the following result −Hello worldAll types of whitespace like spaces, tabs, newlines, etc. are equivalent to the interpreter when they are used outside of the quotes. A line containing only whitespace, possibly with a comment, is known as a blank line, and ...
Read MoreSingle and Double Quotes in Perl
You can use double quotes or single quotes around literal strings as follows −Example#!/usr/bin/perl print "Hello, world"; print 'Hello, world';OutputThis will produce the following result −Hello, world Hello, world$There is an important difference between single and double-quotes. Only double quotes interpolate variables and special characters such as newlines , whereas a single quote does not interpolate any variable or special character. Check below example where we are using $a as a variable to store a value and later printing that value −Example#!/usr/bin/perl $a = 10; print "Value of a = $a"; print 'Value of a = $a';OutputThis will produce the ...
Read More