in reply to how to ignore regex in input to getopt::Long

Couple of things 1. you have to escape the exclamation mark in the command line i.e.  ./scriptname -a sdf\!sdf -b gwerwer 2. following is the code to capture $1 and $2, assuming that you are capturing the value in switch a (-a) in $data
if($data =~ m/(.+)?\!(.+)/) { print "first: $1 , next:$2 \n"; }

Replies are listed 'Best First'.
Re^2: how to ignore regex in input to getopt::Long
by Anonymous Monk on Jun 28, 2010 at 13:23 UTC
    Hi, thanks for replying.
    However, I am trying to have it so that people do not have to escape anything on command line.. is this not possible due to shell interpretation before perl?
      It depends on your OS/shell. In unix-type shells, ! must be escaped because of its special meaning as a command history/substitution character. I just verified this on 3 shells: sh, bash and tcsh.

      However, at a Windows DOS prompt, it is not necessary to escape the !.

      Then don't use a character that has a special meaning for many popular shells. What about ":"?