in reply to Simple Switch statement

Your idea is beautiful, and other responces showed beautiful ideas also.

But DO NOT use eval "goto $_": your code will be vulnerable to hacker crackery: imagine someone will provide to you value of "1;system('rm -rf /')". (I can imagine such a data somewhere in DB and you process it...)

If you do not change this, terrible things could happen.

Courage, the Cowardly Dog

Replies are listed 'Best First'.
Re: Re: Simple Switch statement
by Anonymous Monk on Sep 13, 2003 at 07:17 UTC

    Your particular example won't work.

    #!/usr/bin/perl -wl $_ = q~BOB;print "not good"~; eval "goto $_"; exit; print "hello"; __END__ hello

    However, there is a risk if they use &&. Just being picky. :)

      Ok, consider this:
      1; BEGIN{ system('echo MUAHAHA!!') }
      indeed.

      But hackery crackery was left as an excercise for a reader

      :):):")