[lug] Self-modifying Perl
    Bill Thoen 
    bthoen at gisnet.com
       
    Wed Oct  4 15:39:51 MDT 2006
    
    
  
Is there a way to execute Perl regex commands as variables within Perl? For
eaxmple, this doesn't work, but is something like it possible?
#!/usr/bin/perl
my $cmd = 's/\d/!/g';
while (<>) {
  chop;
  $cmd;
  print "$_\n";
}
What I'd like to be able to do is execute $cmd as if it were the substitute
regex. Ultimately, $cmd would be "fed" from a data file, which would allow
the program to behave differently depend on which data file I feed it.
- Bill Thoen
    
    
More information about the LUG
mailing list