Good Place. Good Things. Good Time.

Perl print

Perl print

Introduction to Perl print

The Perl print is an operator used to display the required output passed as arguments. The Perl print is the output operator that shows any parameter on the display screen. It is useful for display the required output, variable, and object passed as the parameter. The operator is getting the information in the form of machine language and displays the output in the human known language. It gets the string and variable, and after converting it into human language, it will display on the output screen.

Syntax:

Syntax1 is below:

print “display content write here… ”;

  • The “print” is useful to show the output on the screen.
  • The double quotes “…” are useful for writing content, variables, and parameters inside this sign.
  • The semicolon (;) is needed for Perl print content.

Syntax2 is below:

print  (“ display content write here… ”);

  • The double quotes “…” are placed inside of the simple bracket (“…”) and write content and parameters.

How does the print Function Work in Perl?

  • Download and install the Perl latest version in your operating system of the device.

https://www.Perl.org/ or http://strawberryPerl.com/ are mostly using the Perl IDE website link.

  • Create a file with the .pl extension and save the file in the required command line path.

Example:

helloo.pl or firstpearl.pl

  • Create the variables with a dollar sign ($) and initialize with the required value.

$ Variable-name = variable-value;

  • Use the Perl print syntax and write the required parameter inside of the double quotes symbol.

Example:

print “display variable_value : $ Variable-name”;

  • The Perl print syntax working procedure is below.

$ Roll-number = 21;
$ Full-name = “Perl print”;
print  “Roll number: $ Roll-number”;
print  (“Roll number: $ Roll-number”);
print  “Full-name: $ Full-name n”;

Examples of Perl print

Different examples are given below:

Example #1

The simple Perl print example and output are below.

Code:

print  "Hello World with Perl print technology!";
print  " The Perl print is the output operator that shows any parameter on the display      screen. The Perl print is useful for display the required output, variable, and object passed as the parameter. The Perl print operator is getting the information in the form of machine language and displays the result in the human language.  ";

Output:

Perl print 1

Explanation:

  • The print operator displays the user’s information as per requirement.
  • The user’s information is placed inside of the double quotes and adds a semicolon sign.

Example #2

With the next line example, and output are below.

Code:

print  "Hello World with Perl print technology! n";
print  " The Perl print is the output operator that shows any parameter on the display screen. n The Perl print is useful for display the required output, variable, and object passed as the parameter. n The Perl print operator is getting the information in the form of machine language and displays the result in the human language.  ";

Output:

perl print 2

Explanation:

  • You can see the “n” sign symbol after sentence in the double quotes sign.
  • The “n” sign is useful for setting the new line in the display screen.

Example #3

With variable and array, example and output are below.

Code:

$ full_name = "Perl print";
$ roll_number = 21;
$ code = "Perl123";
my @array_number = qw(21, 12, 31, 13, 41, 14);
my @array_name = qw("Perl", "java", "paython", "ruby");
my @array_combo = qw(12, 13, "Perl", "java", "paython", "ruby", 21, 31, 41);
print  "$ full_name n";
print  "$ roll_number n";
print  "$ code n";
print  ("@array_number n");
print  ("@array_name n");
print  ("@array_combo n");

Output:

perl print 3

Explanation:

  • The variable is initialized with the required value and the print operator used with $ sign inside of the double-quotes.
  • The array value initialized with @ sign and print operator used with a simple bracket (“…”) sign.
  • It displays the string, variable, and array as per the user’s desire.

Example #4

With loop and condition, example and output are below.

Code:

$ number1 = "30";
$ number2 = "3";
if ($ number2 < $ number1){
print  " n number 2 is less than number1... n";
}
else{
print  "n  number1 is less than number2... n";
}
while ($number2  >=  1)
{
$number2 = $number2 - 1;
print " lets learn together… n";
}

Output:

with loop and condition

Explanation:

  • The “if” condition is useful for decision-making statements, and the “while” loop is used for checking decrements and increments parameters.
  • The “if” condition displays the “less than” and “greater than” operation, and it shows the output.
  • The “while” loop sets the initial condition, and it presents the required content as per decrements.

Example #5

With single quotes and double quotes, the example and output are below.

Code:

$ string_name = "perl";
print  ("Hello World with $ string_name print technology! n");
print  ('Hello World with $ string_name print technology! n');
print "n";
print  " Hello World with $ string_name print technology! n";
print  'Hello World with $ string_name print technology! n';

Output:

with single quotes and double quotes

Explanation:

  • The single quotes content display variable name, sign, and command-line symbol.
  • The double quotes content display with variable value and working command line.

Conclusion

The Perl print is useful for display the required content on the screen. It is useful to show the required output of the application and parameters.

Recommended Articles

This is a guide to Perl print. Here we discuss the introduction; how does the print function work in Perl? and examples, respectively. You may also have a look at the following articles to learn more –

  1. Perl eval
  2. Perl Hash
  3. Perl for Loop
  4. Perl sort()

The post Perl print appeared first on EDUCBA.

Read original article here: Perl print

Read original article here: Perl print



Disclaimers and Denial of responsibility..!

Denial of responsibility! TheTopMag.com is an automatic aggregator of all media around the world. In each content, the hyperlink to the primary source is specified. All trademarks belong to their rightful owners, all materials to their authors. If you are the owner of the content and do not want us to publish your materials, please contact us by email – jamesonline999@gmail.com . The content will be deleted within 72 hours.
You might also like
Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.