use strict; use warnings; use Data::Dumper; my %actualhash = split /,/, shift; print Dumper \%actualhash;

eval takes whatever you hand to it and tries to compile it as code. So if you hand it print "Hello world.\n" it will print Hello World. Notice how we used quotes? So how about if we hand it say 'Hello world.';? We get the same output (if we use the say feature). And since q// is synonymous with single quotes, we can write that as, eval 'say q/Hello world./;'.

But we also know that the q// operator allows you to use other delimiters, such as q{}, or even q,, (the latter is handy for obfu, and confusing for real world code). By now you should be seeing why putting q, in your input string that you eval may be a problem.

This is an example of why everyone gets nervous and pops a blood pressure pill whenever they start talking about the string form of eval in the same conversation as 'raw user input'. Taint mode would make the very concept of evaling @ARGV args fatal.


Dave


In reply to Re: eval doesn't like the letter 'q'? by davido
in thread eval doesn't like the letter 'q'? by rastoboy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.