# Whitespaces in Perl

PERLServer Side ProgrammingProgramming Scripts

#### Perl Online Training

46 Lectures 4.5 hours

#### COMPLETE PERL Programming

11 Lectures 1.5 hours

#### Perl for Beginners: Learn A to Z of Perl Scripting Hands-on

30 Lectures 6 hours

A Perl program does not care about whitespaces. Following program works perfectly fine −

#!/usr/bin/perl
print    "Hello, world\n";

But if spaces are inside the quoted strings, then they would be printed as is. For example −

## Example

Live Demo

#!/usr/bin/perl
# This would print with a line break in the middle
print "Hello
world\n";

## Output

This will produce the following result −

Hello
world

All 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 Perl totally ignores it.

Updated on 28-Nov-2019 07:38:48