Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between "perl" and "perl -w"?

Tags:

perl

I am learning Perl , very new user . May i know whats the difference between these Perl codes.

#!/usr/bin/perl

&

#!/usr/bin/perl -w
like image 626
rɑːdʒɑ Avatar asked Sep 23 '12 16:09

rɑːdʒɑ


1 Answers

That is not perl code, it's a shebang, which is used in a linux/unix environment as a way to tell the shell what program should be used to run the program file. It has no effect in windows, but it does activate any switches used.

The -w part is a switch for perl, telling it to activate warnings. You can learn more about perl's command line switches by typing perl -h at the command prompt. Read more in perldoc perlrun

-w is the older version of the use warnings pragma, which is preferred nowadays. While -w is global, use warnings is lexical, and can be activated selectively.

like image 152
TLP Avatar answered Sep 18 '22 15:09

TLP