SPUG: Perl logic module?

Marc M. Adkins Perl at Doorways.org
Wed Mar 24 13:18:08 CST 2004

On Wednesday 24 March 2004 07:45 pm, Stuart Poulin wrote:
> Don't forget too that perl has a built in parser - you can sub in strings
> then eval the string. i.e.
> my $str = "-foo bar -a ( -bar stool -o -bar tab )";
> ...
>  return 0;
> }

A perfect example of what I love about Perl.  But then, I was a LISP 
programmer for four years.

My favorite configuration file format for Perl scripts:

		flag1 => 1,
		flag2 => 'two',
		flag3 => [ qw(alpha bravo charlie) ],
		flag4 => {
			title => 'demo',
			priority => 99,
			temperature => 98.6

Q:	How many lines of Perl code does it take to parse the file?
A:	None, because the Perl parser does all the parsing!

Well, not none, of course.  Exactly how many is left as an exercise for the 

The only problem with using this as a general solution is protecting the 
script from a malicious user putting arbitrary code in it.  I use the Safe 
module to protect from that.  I've always suspected the name would turn out 
to be a misnomer some day, but when I search for articles to that effect I 
come up empty.  Anyone know anything about the safety of Safe?


More information about the spug-list mailing list