I have used \
at the end of shell scripts to avoid long lines, and improve code readability.
But I cannot do it in Perl, what am I doing wrong ? Do I have to escape them in any way?
I mean something like:
my $dbh = DBI->connect("DBI:mysql:database=xxxxxxx;host=xxxxxt", "xxxx", "xxxxxx", \%dbattr) or die ("Bla bla bla bla");
Perl statements are terminated separated by a semicolon ;
, you don't need to write code on one line. Your example can be formatted as:
my $dbh = DBI->connect(
"DBI:mysql:database=xxxxxxx;host=xxxxxt",
"xxxx",
"xxxxxx",
\%dbattr
) or
die ("Bla bla bla bla");
Or in any way you like.
You can also take a look at tools like perltidy to automatically beautify your code.
There is no need to escape.
From perldoc perlsyn:
Perl is a free-form language, you can format and indent it however you like. Whitespace mostly serves to separate tokens, unlike languages like Python where it is an important part of the syntax:
my $dbh =
DBI->connect("DBI:mysql:database=xxxxxxx;host=xxxxxt",
"xxxx", "xxxxxx", \%dbattr
)
or die ("Bla bla bla bla");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With