me.at.coding
me.at.coding

Reputation: 17724

Ignore linebreaks in Strings

Is it possible to tell Perl to ignore linebreaks in Strings?

I need linebreaks for formatting reasons as I have very long strings.

E.g.

print "hello 
world"

shall give

hello world

and not

hello
world

Upvotes: 1

Views: 115

Answers (3)

Chankey Pathak
Chankey Pathak

Reputation: 21676

1. Using concatenation

print "hello ". "world";

2. By sending multiple arguments to print function

print ("hello ", "world");

Try it on codepad.

Upvotes: 0

mu is too short
mu is too short

Reputation: 434785

You can pass multiple strings to print instead of one big one:

print "hello", "world";

Assuming of course that you haven't been messing around with $, and that you're really using print.

Upvotes: 2

paddy
paddy

Reputation: 63481

Concatenate your strings

print "hello"
    . "world";

Upvotes: 4

Related Questions