I'm relatively comfortable using perl's regex language, but have a feeling that command line items speak a different form of the regex-speak.
No, Perl stays the same whether it is on the command line or in a script.
But a line like:open(TAR,"tar -czpf $target_file $logs/access_log\.d+\.gz |");
Well, that line looks pretty broken to me. You can't just use a regex anywhere... In your first example, your regex was clearly sitting in the match operator. In this example, it is just sitting in a string. It looks like you are hoping perl will search the directory for you and return the files that match. It won't. You'll have to do that yourself.1
By the way, Perl doesn't change on the command line, but how you have to quote things sometimes does. That doesn't have anything to do with perl actually. It stems from the fact that the shell is between you and perl.
On *nix systems, you'll want to use single quotes. Perl variables inside double quotes can look like variables to your shell. Backwhacks in double quotes are also recognized escapes by your shell. You can put anything in single quotes except more single quotes. If you find yourself really needing single quotes in your perl code on the command line, you can use perl's q() operator.
1. Or, as others have pointed out, let the shell do it for you.
-sauoq "My two cents aren't worth a dime.";
In reply to Re: Acceptable regular expressions within command line type syntax
by sauoq
in thread Acceptable regular expressions within command line type syntax
by Hagbone
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |