in reply to Re^2: grep question
in thread grep question

No, the OP describes the input as a 'param=value' list. I stand by my post.

Replies are listed 'Best First'.
Re^4: grep question
by brian_d_foy (Abbot) on May 26, 2005 at 22:27 UTC

    So, you would rather beleive that the input is always exacctly what you expect rather than add ten characters to handle the situations where it isn't? "Expected user input" tends to not be.

    In general, don't use any of the match variables without knowing the match succeeded. It doesn't matter what else is going on. Don't let yourself get into bad habits, or take shortcuts because you think the data will always be perfect.

    The real answer, however, smells like use CGI;

    --
    brian d foy <brian@stonehenge.com>
      Be fair here: if the user input varies from what the OP specifies then neither my solution nor [id://demerphq]'s stands up; if one of the params is instead say foo, mine prints a bogus $1, and the other skips it altogether. Neither one is particularly good; I would argue that [id://demerphq]'s fails better, but not well.