CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



wdw2130833
New User

Feb 17, 2014, 4:28 PM

Post #1 of 5 (926 views)
Dynamic execute perl script Can't Post

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

#!/usr/bin/perl
use strict;
use warnings;
my $command="my $msg ='this is a test message.';print $msg;";
eval $command ;

THanks!

Bill


BillKSmith
Veteran

Feb 18, 2014, 4:41 AM

Post #2 of 5 (904 views)
Re: [wdw2130833] Dynamic execute perl script [In reply to] Can't Post

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,
Bill


wdw2130833
New User

Feb 18, 2014, 9:11 AM

Post #3 of 5 (892 views)
Re: [BillKSmith] Dynamic execute perl script [In reply to] Can't Post

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


Laurent_R
Veteran / Moderator

Feb 18, 2014, 3:35 PM

Post #4 of 5 (879 views)
Re: [wdw2130833] Dynamic execute perl script [In reply to] Can't Post

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.


wdw2130833
New User

Feb 19, 2014, 4:17 PM

Post #5 of 5 (859 views)
Re: [Laurent_R] Dynamic execute perl script [In reply to] Can't Post

Thanks.
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!


Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives