[lug] Re: Self-modifying Perl

mohadib mohadib at openactive.org
Wed Oct 4 20:33:48 MDT 2006


one last word :)

passing in a block of code is pretty standard
in a lot of languages. In Java interfaces are used.
In perl i think you could do similar by passing a function
with your data. Im no perl hacker ;)

jd


On Wed, 2006-10-04 at 19:22 -0600, mohadib wrote:
> Here it is
> 
> (??{$rule})  
> 
> $rule is a random regex in a string iirc
> 
> hth,
> jd
> 
> 
> On Wed, 2006-10-04 at 18:10 -0600, mohadib wrote:
> > I have seen perl syntax that lets you store regex , saw it in perl
> > appoclypse 5 I think.
> > 
> > fyi,
> > jd
> > 
> > On Wed, 2006-10-04 at 15:52 -0600, Bill Thoen wrote:
> > > Never mind... I just discovered the 'eval' command and answered my own
> > > question!
> > > 
> > > On Wed, Oct 04, 2006 at 03:39:51PM -0600, Bill Thoen wrote:
> > > > 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
> > > > 
> > > _______________________________________________
> > > Web Page:  http://lug.boulder.co.us
> > > Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> > > Join us on IRC: lug.boulder.co.us port=6667 channel=#colug
> > 
> > _______________________________________________
> > Web Page:  http://lug.boulder.co.us
> > Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> > Join us on IRC: lug.boulder.co.us port=6667 channel=#colug
> 
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: lug.boulder.co.us port=6667 channel=#colug




More information about the LUG mailing list