in reply to Getopt, regexen, and newlines

Did you check what your Perl script actually gets in @ARGV? The following will clarify to you what I suspect is the cause:

BEGIN { local $" = "] ["; print "Command line: [@ARGV]\n";

Most likely, your shell interprets the backslash (and other regex metacharacters) as a special character.... Of course, different shells handle the commandline differently, so the set of metacharacters may range from +/&;*"^% (Win32) to +/&!$\'"()[]{} (many *sh variants).

Replies are listed 'Best First'.
Re^2: Getopt, regexen, and newlines
by apotheon (Deacon) on Oct 12, 2005 at 18:38 UTC

    The shell does indeed sanitize the arguments, unless I quote them. However, quoting them doesn't change the effect of the script, which still ends up giving me sanitized escape characters rather than newlines.

    Of course, I should have mentioned as much in the original post, and I'll go add something about that as a note now. I'll rep++ you for pointing that out.

    print substr("Just another Perl hacker", 0, -2);
    - apotheon
    CopyWrite Chad Perrin

      Backslashed characters are just backslashed characters unless Perl reads them in a double-quotish context. To do that, see efficient char escape sequence substitution.

      Caution: Contents may have been coded under pressure.