Help for this page

Select Code to Download


  1. or download this
    my $sub= eval "sub { my($x)=@_; return ($x/2)**4 }";
    die $@   if  $@;
    for my $x (  0..100  ) {
    ...
        my $y= $sub->( $x );
        plot( $x, $y );
    }
    
  2. or download this
    if(  $equ =~ m#[^-\s\d+*/()]#  ) {
        # refuse to use it
    
  3. or download this
    my $equ= $q->param("equation");
    my( $var, $expr )= $equ =~ /^\s*(\w+)\s*=(.*)/
      or  fail("Invalid equation");
    ...
    $expr =~ s/(\w+)/ $words{$1} /ge;
    my $sub= eval 'sub { my($x,$y,$z)= @_; return ' . $expr . '}';
    fail( "Invalid expression ($expr): $@" )  if  $@;