in reply to Re^2: run-time syntax checking
in thread run-time syntax checking

root@Captain:/home/pardus# perl my $string = "print 'some string'; }"; my $sub = eval "sub { $string }"; print $@; Unmatched right curly bracket at (eval 1) line 1, at end of line syntax error at (eval 1) line 1, near "} }"
So where is the surprise ?
--
Jaap Karssenberg || Pardus (Larus)? <pardus@cpan.org>
>>>> Zoidberg: So many memories, so many strange fluids gushing out of patients' bodies.... <<<<

Replies are listed 'Best First'.
Re^4: run-time syntax checking
by Aristotle (Chancellor) on Feb 01, 2003 at 16:28 UTC
    How about
    my $string = '}{ print "Bwahaha!\n"; system("rm -rf /")';

    Makeshifts last the longest.

      Hmmm - I *really* should do development as a non-root user ...

      But say I do pre-parse the string to check for unmatched curlies, I check for BEGIN and END blocks and I strip comments. Is eval "sub { $string }" usefull under these conditions ?

      I don't care for security really -- I trust users to not intentionally fuck up the system.
      --
      Jaap Karssenberg || Pardus (Larus)? <pardus@cpan.org>
      >>>> Zoidberg: So many memories, so many strange fluids gushing out of patients' bodies.... <<<<

        And then how about $string = qq[print = "Hey look, a mushroom!  {==" ]? You can't parse Perl. Keep in mind that BEGIN is also spelled "use".


        Seeking Green geeks in Minnesota