in reply to How to make perl accept symbol open/close bracket?

Most probably this is not a Perl issue but a shell issue.

Try quoting the arguments you supply to your script on the command line, e.g.

$ ./shellArgs.pl 'abc' '(abc)' 'evg'
rather than
$ ./shellArgs.pl abc (abc) evg
Note that 'abc' and 'evg' need not be quoted, strictly speaking, so
$ ./shellArgs.pl abc '(abc)' evg
works just as well.

Hope this helps, -gjb-

Replies are listed 'Best First'.
Re: Re: How to make perl accept symbol open/close bracket?
by hyliau (Initiate) on Jun 27, 2003 at 10:15 UTC
    hi,
    still not working using the '(abc)' as an example.

    pls refer to below example of $ARGV2 value which contains the symbol open/close bracket.

    Message from user AUDIT on SMDI22 Security alarm \(SECURITY\) and security audit \(SECURITY\) on SMDI22, + system id: 62940 Auditable event: Remote interactive breakin detection Event time: 26-JUN-2003 17:52:51.48 PID: 20405AE3 Process name: _TNA147: Username: HJKH Terminal name: TNA147:, _TNA147:, Host: 100.10.80.100 Po +rt: 59469 Remote node id: 1678397540 Remote node fullname: 100.10.80.100 Remote username: TELNET_640A5064 Status: %LOGIN-F-NOSUCHUSER, no such user

      gjb is correct. The problem is in your shell. Perl doesn't care if you have parenthesis in your variable (except maybe in a regex). I assume the message you printed above in output from something. The parenthesis are escaped because someone programmed it to do that. That has nothing to do with the input of the program.

      I copied your program and ran it and it worked fine as long as the arguments are quoted. It might be a difference in shells (I use bash on Linux) so you might try escaping the parenthesis by using a \ character.

      Hope that helps

      Lobster Aliens Are attacking the world!
        Thanks for your guideline.
        Here is the way that I tested. In unix command prompt.

        # perl multi.pl a b ccc-ddd_eee\ > fff:ggg.hhh, iii(jjj)lllll /sbin/sh: Syntax error: `(' is not expected. #