Putting code in a variable and running interactively?

From: Jimmy Phillips (sendto_at_spammers.com)
Date: 08/25/04


Date: Tue, 24 Aug 2004 20:44:55 -0500

I am fairly new to Perl so I wasn't real sure how to title this.

I want to build a regex interactively in a program and then run it. So
far I do it by writing it to a file along with the Perl envelope around it
then calling it from my program. Works ok but seems clunky. Then I found
a tutorial about executing perl code in a regular expression but so far it
hasn't quite worked the way I want.

So... Is it possible to put a legimate line of Perl code in a variable,
then (somehow) execute that variable. Sort of like so...

$z = "Print amount";
(execute) $z;

Or put another way. Build program B within program A then run program B
within the original program A?

If this was a standard programming environment like Builder or Kylix I
wouldn't even ask such a rediculous question, but in my so far brief
experience with Perl I haven't found much it won't to.

JP



Relevant Pages

  • [Full-Disclosure] PR0V1NG RFP WR0NG
    ... Agree that the presented Perl code has issues, and I agree that it's very ... I've taken a sample perl test script which reads: ... Server: Netscape-Enterprise/4.1 ... I'm a washed out sell out capitalizing on my 10 seconds of fame for writing some crappy advisories and some shitty perl code. ...
    (Full-Disclosure)
  • Re: recursion with perl
    ... > know that there is a perl sort function but I am doing this so that I ... I pasted my perl code ... prevent uninteded use of global variables. ...
    (comp.lang.perl)
  • Re: Parsing a file that has labels
    ... Let me explain the above perl code. ... As such a character doesn't exist that means the whole ... replace every occurrence of the regexp, ...
    (comp.unix.shell)
  • Re: Parsing a file that has labels
    ... > Let me explain the above perl code. ... there's something to know about perl regexps. ... As such a character doesn't exist that means the whole ... replace every occurrence of the regexp, ...
    (comp.unix.shell)
  • RE: perl DBI oracle and error ORA 06502
    ... procedure, schema, some data and the exact perl code that calls it. ... I would also need the name of and version your OS, perl, DBI, ... DBD::Oracle, The Oracle client you are running and the Oracle DB ... The problem shows in the perl code. ...
    (perl.dbi.users)