How to remove all spaces and lines in Perl?

I have a line that looks like this ...

"
http://www.example.com/

example.pdf "

I need to remove spaces and line breaks. How should I do it? My result should be

"http://www.example.com/example.pdf"

+5
source share
2 answers

Just use the replace statement : s///

$string =~ s/\s+//g;

A class \s matches a space character, a set, [\ \t\r\n\f]and others.

+17
source
while (<>) { s/\s+//g; print; }

?

0
source

All Articles