Home: Perl Programming Help: Beginner:
Dynamic execute perl script

New User

Feb 17, 2014, 4:28 PM

Views: 2882
Dynamic execute perl script

I am new to perl. I just want to confirm if I can dynamically execute some perl codes in a perl script like this:

use strict;
use warnings;
my $command="my $msg ='this is a test message.';print $msg;";
eval $command ;




Feb 18, 2014, 4:41 AM

Views: 2860
Re: [wdw2130833] Dynamic execute perl script

The short answer is "yes", if you fix the quotes (Change single to double and double to single).

It probably is not a good way to do what you want. Please tell us more about what you really are trying to do.
Good Luck,

New User

Feb 18, 2014, 9:11 AM

Views: 2848
Re: [BillKSmith] Dynamic execute perl script

Thank you! It's working now after changing the double quotes and single quotes.

Veteran / Moderator

Feb 18, 2014, 3:35 PM

Views: 2835
Re: [wdw2130833] Dynamic execute perl script

Yes, but this seems to be still a very poor way of doing it. As Bill told you, please tell us more on what you are trying to achieve.

New User

Feb 19, 2014, 4:17 PM

Views: 2815
Re: [Laurent_R] Dynamic execute perl script

I was working on PowerShell to build alerts. So I can send a main powershell script to remote server, this main script will generate some sub-scripts on remote server based on different situations, and dynamically collect alert data.

I am looking for the same functions in Perl.

Not sure how powerful it is for eval command in Perl.

Thank you!