Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a Perl BEGIN block spread a virus or lose data?

I am still new to Perl. Since BEGIN blocks are run during compilation can't a virus spread or data loss occur from simply compiling? Does Perl do anything to stop it? If so does it mean the code in BEGIN blocks may act differently outside of it?

like image 834
An employee Avatar asked Oct 02 '09 20:10

An employee


2 Answers

Yes to all these questions. The Eclipse IDE was vulnerable to this. It discussed in more detail here.

As with all software, you should avoid downloading and running anything from a source you do not trust. CPAN is generally trustworthy; although I am not aware of anyone intentionally releasing rogue code to CPAN, it's possible it has happened.

You can avoid running code during compile checks with the $^C flag, e.g.:

BEGIN { load_data_from_db() unless $^C; }
like image 120
Ether Avatar answered Sep 18 '22 23:09

Ether


chromatic explains how a Perl program works.

like image 29
deepakg Avatar answered Sep 22 '22 23:09

deepakg