Exercise: Remove a Newline Character

Remove a newline from the beginning of a scalar.

Problem statement

In this challenge, you have to remove a new line from the beginning of a scalar variable.

Given a variable $var, you need to remove the newline character, if there is any, from the beginning of the string, and then display it using:

print $var;

Sample input

my $var = '\nWhat';

Expected output


Coding challenge

This is a simple problem related to using scalar operators. Assume that the variable $var has already been defined.

If you feel stuck, you can always refer to the solution review in the next lesson.

Good luck!

Get hands-on with 1200+ tech skills courses.